// This script performs an INSERT query to add a record to the users table.
$page_title='Search';
include('includes/header.html');
// Check for form submission:
// echo $_SERVER['REQUEST_METHOD'];
if($_SERVER['REQUEST_METHOD']=='POST'){//remember the difference between post and get?
require('./mysqli_connect.php');// Connect to the db.
$errors=array();// Initialize an error array.
// Check for an email address:
if(empty($_POST['first_name'])){//$_POST is a global variable. empty() method determines whether a variable is considered to be empty.
$errors[]='You forgot to enter the first name';
}else{
$fn=mysqli_real_escape_string($dbc,trim($_POST['first_name']));//mysqli_real_escape_strin()escapes special characters in a string for use in an SQL statement.
}
if(empty($errors)){// If there is no errors. If everything's OK.
// Make the query:
$q="SELECT CONCAT(StuLastName, ', ', StuFirstName) AS name, StuEmail, Mobile FROM Students where StuFirstName='$fn'";
$r=@mysqli_query($dbc,$q);// Run the query.
$num=mysqli_num_rows($r);
if($num>0){// If it ran OK, display the records.
// Print how many users there are:
echo"<p>There is the information for the student you are looking for.</p>\n";
if($_SERVER['REQUEST_METHOD']=='POST'){//remember the difference between post and get?
require('./mysqli_connect.php');// Connect to the db.
$errors=array();// Initialize an error array.
// Check for an email address:
if(empty($_POST['last_name'])){//$_POST is a global variable. empty() method determines whether a variable is considered to be empty.
$errors[]='You forgot to enter the last name';
}else{
$fn=mysqli_real_escape_string($dbc,trim($_POST['last_name']));//mysqli_real_escape_strin()escapes special characters in a string for use in an SQL statement.
}
if(empty($errors)){// If there is no errors. If everything's OK.
// Make the query:
$q="SELECT CONCAT(LecLastName, ', ', LecFirstName) AS lecname, LecEmail, WTel FROM Lecturers where LecLastName='$fn'";
$r=@mysqli_query($dbc,$q);// Run the query.
$num=mysqli_num_rows($r);
if($num>0){// If it ran OK, display the records.
// Print how many lecturers there are:
echo"<p>There is the information for the lecturer you are looking for.</p>\n";