0% found this document useful (0 votes)
35 views

Web Project - Part I

The document contains PHP code for customer registration. It starts a session, generates a unique customer ID number, and displays a registration form. It collects customer details submitted in the form, saves it to a database table called "Customer", and displays a success or error message. Key sections include generating a unique ID, displaying the registration form, validating and saving submitted details to the database.

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)
35 views

Web Project - Part I

The document contains PHP code for customer registration. It starts a session, generates a unique customer ID number, and displays a registration form. It collects customer details submitted in the form, saves it to a database table called "Customer", and displays a success or error message. Key sections include generating a unique ID, displaying the registration form, validating and saving submitted details to the database.

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

cusNumGen.

php

<?php

session_start();

?>

<!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>Untitled Document</title>

<style type="text/css">

<!--

body,td,th {

font-family: Calibri;

font-size: 16px;
color: #000066;

body {

background-color: #D2FBFB;

-->

</style></head>

<body>

<?php

$conn=mysqli_connect('localhost','root','','hnd_28_final');

if($conn){

$queNum="SELECT CusID FROM Customer";

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

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

$sno=0;

if(mysqli_num_rows($dRes)>0){

$queMax="SELECT MAX(SerialNo) FROM Customer";

$dataR=mysqli_query($conn,$queMax);

$dVal=mysqli_fetch_assoc($dataR);

$sno=$dVal['MAX(SerialNo)'];

$sno+=1;

else{

$sno=1;

$cid='SEA-'.$sno;
$_SESSION['cid']=$cid;

header("Location:CusReg.php");

else{

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

?>

</body>

</html>

CusReg.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;

}
.style1 {color: #000033}

.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;

td{

vertical-align:top;

-->

</style></head>

<?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%"><br>

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

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

<tr>

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

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

</tr>
<tr>

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

<td colspan="2" bgcolor="#000033"><span class="style1"></span></td>

</tr>

<tr>

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

<td width="33%"><span class="style3"><font


color="#ff0000">'.$_SESSION['cid'].'</font></span></td>

<td colspan="2">&nbsp;</td>

</tr>

<tr>

<td colspan="2">First Name</td>

<td colspan="2">Last Name</td>

</tr>

<tr>

<td colspan="2"><label>

<input name="txtFName" type="text" class="style4" id="txtFName" size="40" maxlength="40" />

</label></td>

<td colspan="2"><input name="txtLName" type="text" class="style4" id="txtLName" size="50"


maxlength="60" /></td>

</tr>

<tr>

<td colspan="2">NIC</td>

<td colspan="2">Contact Number</td>

</tr>

<tr>

<td colspan="2"><input name="txtNIC" type="text" class="style4" id="txtNIC" size="15"


maxlength="12" /></td>

<td colspan="2"><input name="txtConNo" type="text" class="style4" id="txtConNo" size="12"


maxlength="10" /></td>
</tr>

<tr>

<td colspan="2">Address</td>

<td width="33%">Date of Birth</td>

<td width="26%"> Gender</td>

</tr>

<tr>

<td colspan="2" rowspan="3"><label>

<textarea name="txtAdd" cols="50" rows="5" class="style4" id="txtAdd"></textarea>

</label></td>

<td><input name="txtDOB" type="text" class="style4" id="txtDOB" size="12" maxlength="10"


/></td>

<td><label>

<input type="radio" name="rbGen" id="rbGen" value="Male" />

Male

<input type="radio" name="rbGen" id="rbGen" value="Female" />

Female

</label></td>

</tr>

<tr>

<td>&nbsp;</td>

<td>Civil Status</td>

</tr>

<tr>

<td>&nbsp;</td>

<td><input name="rbCs" type="radio" id="rbCs" value="Married" />

Married

<input name="rbCs" type="radio" id="rbCs" value="Unmarried" />

Unmarried</td>
</tr>

<tr>

<td colspan="2"><label>

<div align="center">

<input name="btnSave" type="submit" class="style5" id="btnSave" value="SAVE" />

</div>

</label></td>

<td colspan="2"><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>

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

</tr>

</table>

</form>

</td>

</tr>

</table>';

?>

<body>

</body>

</html>
regProc.php

<?php

session_start();

?>

<!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>Untitled Document</title>

<style type="text/css">

<!--

body,td,th {

font-family: Calibri;

font-size: 16px;

color: #000066;

body {

background-color: #D2FBFB;

-->

</style></head>

<body>

<?php

$cid=$_SESSION['cid'];

$cname=$_POST['txtFName'].' '.$_POST['txtLName'];

$nic=$_POST['txtNIC'];

$conNo=$_POST['txtConNo'];
$add=$_POST['txtAdd'];

$dob=$_POST['txtDOB'];

$gen=$_POST['rbGen'];

$cs=$_POST['rbCs'];

if($gen=='Male'){$tit='Mr.';}

else if($cs=='Unmarried'){$tit='Miss.';}

else{$tit='Mrs.';}

$conn=mysqli_connect('localhost','root','','hnd_28_final');

if($conn){

$queSave="INSERT INTO
Customer(CusID,CusName,NIC,ConNo,CAdd,DOB,Gender,CStat,Title)
VALUES('$cid','$cname','$nic','$conNo','$add','$dob','$gen','$cs','$tit')";

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

echo $cid.' Successfully SAVE to the Database!<br><a href="Main.php"><img


src="Imgs/BackIcon.png" width="30" height="30"></a>';

else{

echo 'Data Not SAVE to the Database'.mysqli_error($conn);'<br>

<a href="cusNumGen.php"><img src="Imgs/BackIcon.png" width="30"


height="30"></a>';

else{

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

?>

</body>

</html>
Customer Table:

You might also like