0% found this document useful (0 votes)
36 views12 pages

Web Proj - III (Search & Search Result Pages)

The PHP code is for a hotel booking website that allows users to search for customer details after logging in. It includes code for the login page, customer search page, and customer details display page. The login page checks for a session variable and displays the logged in user's name. The search page has a form to enter a customer ID or leave blank to see all. It connects to a database and queries customer details to display based on the ID searched or all if blank.

Uploaded by

Dinuka Sudara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views12 pages

Web Proj - III (Search & Search Result Pages)

The PHP code is for a hotel booking website that allows users to search for customer details after logging in. It includes code for the login page, customer search page, and customer details display page. The login page checks for a session variable and displays the logged in user's name. The search page has a form to enter a customer ID or leave blank to see all. It connects to a database and queries customer details to display based on the ID searched or all if blank.

Uploaded by

Dinuka Sudara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Search.

php

Code :

<?php

session_start();

if(isset($_SESSION['RName'])){

echo '<table border="0" width="100%" cellpadding="0" cellspacing="0" align="center">

<tr>

<td colspan="2"><img src="Imgs/back.jpg" width="100%"></td>

</tr>

<tr>

<td colspan="2" align="right" bgcolor="#5FB3E0">You are logged in as


'.$_SESSION['RName'].'! <a href="Logout.php">(Logout!)</a></td>

</tr>';

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>SeaBreeze.com</title>

<style type="text/css">

<!--

body,td,th {

font-family: Calibri;

font-size: 16px;

color: #000066;

body {

background-color: #D2FBFB;

.style3 {

color: #CCCCCC;

font-size: 20px;

font-weight: bold;

font-style: italic;

.style4 {

font-size: 18px;

color: #000000;

.style5 {

font-size: 24px;

color: #000099;
font-weight: bold;

.style7 {

font-size: 12px;

color: #FF0000;

font-style: italic;

-->

</style></head>

<body>

<?php

echo '<tr>

<td width="25%">

<table width="100%" cellpadding="0" cellspacing="5" border="0">

<tr>

<td align="left" bgcolor="#9991E6">CUSTOMER</td>

</tr>

<tr>

<td align="right"><a href="cusNumGen.php"><img src="Imgs/CusReg.png"></a></td>

</tr>

<tr>

<td align="right"><a href="Search.php"><img src="Imgs/Se.png"></a></td>

</tr>

<tr>

<td align="left" bgcolor="#9991E6">ROOMS</td>

</tr>

<tr>

<td align="right"><a href="roomRes.php"><img src="Imgs/RoomRes.png"></a></td>


</tr>

<tr>

<td align="left" bgcolor="#9991E6">PAYMENT</td>

</tr>

<tr>

<td align="right"><a href="pay.php"><img src="Imgs/Pay.png"></a></td>

</tr>

</table>

</td>

<td width="75%">

<form id="form1" name="form1" method="post" action="SearchRes.php">

<table width="29%" height="235" border="0" align="center" cellpadding="5" cellspacing="0">

<tr>

<td colspan="2" bgcolor="#7291CB">&nbsp;</td>

</tr>

<tr>

<td colspan="2" bgcolor="#000033"><span class="style3">CUSTOMER SEARCH</span></td>

</tr>

<tr>

<td width="39%">Customer ID</td>

<td width="61%"><label>

<input name="txtCusID" type="text" class="style4" id="txtCusID" />

</label></td>

</tr>

<tr>

<td colspan="2"><span class="style7">*** To Search all Customers, Keep the above Text Box
Empty</span></td>

</tr>

<tr>
<td><label>

<div align="center">

<input name="btnSearch" type="submit" class="style5" id="btnSearch" value="SEARCH" />

</div>

</label></td>

<td>

<div align="center">

<input name="btnCl" type="reset" class="style5" id="btnCl" value="CLEAR" />

</div></td>

</tr>

<tr>

<td colspan="2" bgcolor="#7291CB">&nbsp;</td>

</tr>

</table>

</form>

</td>

</tr>

</table>';

?>

</body>

</html>
SearchRes.php

Code :

<?php

session_start();

if(isset($_SESSION['RName'])){

echo '<table border="0" width="100%" cellpadding="0" cellspacing="0" align="center">

<tr>

<td colspan="2"><img src="Imgs/back.jpg" width="100%"></td>

</tr>

<tr>

<td colspan="2" align="right" bgcolor="#5FB3E0">You are logged in as


'.$_SESSION['RName'].'! <a href="Logout.php">(Logout!)</a></td>

</tr>';

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>SeaBreeze.com</title>

<style type="text/css">

<!--

body,td,th {

color: #000066;

font-family: Calibri;

font-size: 14px;

body {

background-color: #D2FBFB;

td{

vertical-align:top;

.style3 {

color: #CCCCCC;

font-size: 20px;

font-weight: bold;

font-style: italic;

-->

</style></head>

<body>
<?php

echo '<tr>

<td width="25%">

<table width="100%" cellpadding="0" cellspacing="5" border="0">

<tr>

<td align="left" bgcolor="#9991E6">CUSTOMER</td>

</tr>

<tr>

<td align="right"><a href="cusNumGen.php"><img src="Imgs/CusReg.png"></a></td>

</tr>

<tr>

<td align="right"><a href="Search.php"><img src="Imgs/Se.png"></a></td>

</tr>

<tr>

<td align="left" bgcolor="#9991E6">ROOMS</td>

</tr>

<tr>

<td align="right"><a href="roomRes.php"><img src="Imgs/RoomRes.png"></a></td>

</tr>

<tr>

<td align="left" bgcolor="#9991E6">PAYMENT</td>

</tr>

<tr>

<td align="right"><a href="pay.php"><img src="Imgs/Pay.png"></a></td>

</tr>

</table>

</td>

<td width="75%">';

$cid=$_POST['txtCusID'];
$conn=mysqli_connect('localhost','root','','hnd_28_final');

if($conn){

if(!empty($cid)){

$res="SELECT * FROM customer WHERE CusID='$cid'";

if(mysqli_query($conn,$res)){

$dRes=mysqli_query($conn,$res);

if(mysqli_num_rows($dRes)>0){

echo '<table width="100%" align="center" border="0" cellpadding="5" cellspacing="0">

<tr>

<th colspan="9" align="left"


bgcolor="#000033"><span class="style3">Details of Customer ID : '.$cid.':</span><th>

</tr>

<tr>

<th>Customer Name</th>

<th>NIC</th>

<th>Contact No.</th>

<th>Address</th>

<th>Date of Birth</th>

<th>Gender</th>

<th>Civil Status</th>

<th>&nbsp;</th>

<th>&nbsp;</th>

</tr>';

while($rowVal=mysqli_fetch_assoc($dRes)){

echo '<tr>
<td>'.$rowVal['Title'].$rowVal['CusName'].'</td>

<td>'.$rowVal['NIC'].'</td>

<td>'.$rowVal['ConNo'].'</td>

<td>'.$rowVal['CAdd'].'</td>

<td>'.$rowVal['DOB'].'</td>

<td>'.$rowVal['Gender'].'</td>

<td>'.$rowVal['CStat'].'</td>

<td><a
href="Edit.php?id='.$cid.'"><img src="Imgs/EditImg.png" width="30" height="30"></a></td>

<td><a
href="Delete.php?id='.$cid.'"><img src="Imgs/DelImg.png" width="30" height="30"></a></td>

</tr>';

echo '</table>';

else{

$res="SELECT * FROM customer";

if(mysqli_query($conn,$res)){

$dRes=mysqli_query($conn,$res);

if(mysqli_num_rows($dRes)>0){

echo '<table width="100%" align="center" border="0" cellpadding="5" cellspacing="0">

<tr>

<th>Customer ID</th>

<th>Customer Name</th>

<th>NIC</th>
<th>Contact No.</th>

<th>Address</th>

<th>Date of Birth</th>

<th>Gender</th>

<th>Civil Status</th>

<th>&nbsp;</th>

<th>&nbsp;</th>

</tr>';

while($rowVal=mysqli_fetch_assoc($dRes)){

echo '<tr>

<td>'.$rowVal['CusID'].'</td>

<td>'.$rowVal['Title'].$rowVal['CusName'].'</td>

<td>'.$rowVal['NIC'].'</td>

<td>'.$rowVal['ConNo'].'</td>

<td>'.$rowVal['CAdd'].'</td>

<td>'.$rowVal['DOB'].'</td>

<td>'.$rowVal['Gender'].'</td>

<td>'.$rowVal['CStat'].'</td>

<td><a
href="Edit.php?id='.$rowVal['CusID'].'"><img src="Imgs/EditImg.png" width="30"
height="30"></a></td>

<td><a
href="Delete.php?id='.$rowVal['CusID'].'"><img src="Imgs/DelImg.png" width="30"
height="30"></a></td>

</tr>';

echo '</table>';

}
}

else{

echo '<h4>ERROR 369</h4><br>Database is NOT CONNECTED!';

echo '</td>

</tr>

</table>';

?>

</body>

</html>

You might also like