3. Introduction
This documents contains few web applications written in PHP and HTML scripting language
that would allow a user to interact with a MySQL database
Development Tools
Database Platform: MySQL
Web Scripting Languages: PHP and HTML
Web Server: EASY PHP 5.3.8.1 with Apache
6. Verify that the information has been inserted into the database to their corresponding table. Student is
the database and school is the table. To accomplish this task, a query is needed.
7.
8. Student Application System Codes
<?php
/*****************************************************
This display array POST
*****************************************************/
//echo "<pre>";
//print_r($_POST);
//echo "</pre>";
/*****************************************************
Create variables with information from array POST
*****************************************************/
$FirstName = $_POST["FirstName"];
$LastName = $_POST["LastName"];
$Email=$_POST["Email"];
$Gender =$_POST ["Gender"];
$Password=$_POST["Password"];
$ConfirmPassword=$_POST ["ConfirmPassword"];
$StudentYear=$_POST["StudentYear"];
$Interest=$_POST["Interest"];
$picture = $_POST["picture"];
$profile = $_POST["profile"];
$Sports = $_POST["Sports"];
/*************************************
connect to mysql
********************************************/
$server = "Localhost"; // Server name
$user = "root"; // User name
$pass = "" ; // password
$connect = mysql_connect($server, $user, $pass)
or die ("Error: Bad connection" );
$sel = mysql_select_db('school') or die("Error: Bad connection");
$sql = "INSERT INTO Student (FirstName, LastName, Email, Gender, Password,
ConfirmPassword, StudentYear, Interest, picture, profile, Sports)";
$sql .= "VALUES ("$FirstName", "$LastName", "$Email",
"$Gender","$Password", "$ConfirmPassword", "$StudentYear",
"$Interest", "$picture","$profile", "$Sports" )";
$query = mysql_query($sql);
$numRows = mysql_affected_rows($connect);
if ($numRows == 1)
echo
"<h1> New student added</h1>";
11. </body
</html>
<Database>
Drop database if exists school;
Create database if not exists school;
Use school;
CREATE TABLE student(
StudentID int NOT NULL AUTO_INCREMENT,
FirstName char(20) NOT NULL,
LastName char(20) NOT NULL,
Email varchar(30) NOT NULL,
Gender char(6) NOT NULL,
Password Varchar(20) NOT NULL,
ConfirmPassword Varchar(20) NOT NULL,
StudentYear char(11) NOT NULL,
Interest Text NOT NULL,
Picture char (20) NOT NULL,
Profile char(20) NOT NULL,
Sports char(42) NOT NULL,
PRIMARY KEY(StudentID)
);
Student Application System 2
Instead of having the user login in to the database to access the data, the user can open a web
application which displays the content of the database back to them for security reasons.
12. Student Application System 2 Code
<?php
//echo "<pre>";
//print_r($_POST);
//echo "</pre>";
/**********************************************
connect to mysql
********************************************/
$server = "Localhost"; // Server name
$user = "root"; // User name
$pass = "" ; // password
/********************************************
Display message if connection falied
**********************************************/
$connect = mysql_connect($server, $user, $pass)
or die ("Error: Bad connection" );