0% found this document useful (0 votes)
31 views16 pages

WDD Project - I

The document outlines a sample web project consisting of a login system with HTML, PHP, and CSS components. It includes a login form, user authentication, session management, and a template for maintaining consistent design across pages. The project also features a logout functionality and uses an external CSS file for styling.

Uploaded by

ushan.sasika
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)
31 views16 pages

WDD Project - I

The document outlines a sample web project consisting of a login system with HTML, PHP, and CSS components. It includes a login form, user authentication, session management, and a template for maintaining consistent design across pages. The project also features a logout functionality and uses an external CSS file for styling.

Uploaded by

ushan.sasika
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/ 16

Sample Project

Login.html

html Code :

<!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: 18px;

color: #FFFFFF;

body {

background-color: #3A3D8F;

.style1 {
font-size: 24px;

font-weight: bold;

font-style: italic;

.style3 {font-size: 24px; font-weight: bold; font-style: italic; color: #009933; }

.style5 {font-size: 24px; font-weight: bold; font-style: italic; color: #666666; }

-->

</style></head>

<body>

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

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

<table width="37%" border="0" align="center" cellpadding="5" cellspacing="0">

<tr>

<th colspan="3" bgcolor="#3033AD" scope="col">&nbsp;</th>

</tr>

<tr>

<th colspan="2" bgcolor="#0066FF" scope="row"><div align="left" class="style1">LOGIN</div></th>

<td width="34%" rowspan="4"><img src="Imgs/log.png" width="154" height="154" /></td>

</tr>

<tr>

<th width="22%" scope="row"><div align="left">Username</div></th>

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

<input name="txtUN" type="text" id="txtUN" size="30" maxlength="30" />

</label></td>

</tr>
<tr>

<th scope="row"><div align="left">Password</div></th>

<td><input name="txtPW" type="password" id="txtPW" size="30" maxlength="30" /></td>

</tr>

<tr>

<th scope="row"><label>

<input name="btnLogin" type="submit" class="style3" id="btnLogin" value="LOGIN" />

</label></th>

<td><div align="center">

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

</div></td>

</tr>

<tr>

<th colspan="3" bgcolor="#3033AD" scope="row">&nbsp;</th>

</tr>

</table>

</form>

</body>

</html>

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

</head>

<body>

<?php

$un=$_POST['txtUN'];

$pw=$_POST['txtPW'];

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

if($conn){

$queLog="SELECT * FROM usertbl WHERE Username='$un' AND Password='$pw'";

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

$rest=mysqli_query($conn,$queLog);

if(mysqli_num_rows($rest)>0){

$val=mysqli_fetch_assoc($rest);

if($val["Password"]==$pw){

$_SESSION['RName']=$val["RealName"];

$rN=$_SESSION['RName'];

$queSave="INSERT INTO logsch(RealName,LIN) VALUES('$rN',(now()))";

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

header("Location:Main.php");
}

else{

echo 'Incorrect Username or Password!<br>

<a href="Login.html"><img src="Imgs/back.png" width="50" height="50"></a>';

else{

echo 'Login Query Not execute!'.mysqli_error($conn);

else{

echo 'Database is NOT Connected!'.mysqli_error($conn);

?>

</body>

</html>
In this Sample web system need to maintain same page design throughout the project. So for that purpose
will create the following template page & it will not a part of the project. But when creating the Main page
& the rest of the other pages, will use the code of the template to maintain the design.

In this project the design is maintain by external CSS file as well.

ProjDesign.css
@charset "utf-8";

body{

margin:12px;

background:#E1F3F4;

font-family:Calibri;

font-size:18px;

.sidebar{

grid-area:sidebar;

.content{

grid-area:content;

.header{

grid-area:header;

.footer{

grid-area:footer;
}

.wrapper{

display:grid;

grid-gap:2px;

grid-template-columns:20% 80%;

grid-template-areas:

"header header"

"sidebar content"

"footer footer";

background:#3A3D8F;

.box{

background-color:#003366;

color:#FFFFFF;

border-radius:0px;

padding:10px;

margin:0px;

a:link{

background-color:#9A9AE2;

border:1px solid #2929BC;

color:#00FFFF;

text-align:center;
text-decoration:none;

display:inline-block;

opacity:0.5;

border-radius:3px;

margin:3px;

a:visited{

background-color:#428A88;

border:1px solid #4A4A8E;

color:#CCCCCC;

text-align:center;

text-decoration:none;

display:inline-block;

opacity:0.5;

border-radius:3px;

margin:3px;

a:hover{

background-color:#4BFEFA;

border:1px solid #098481;

color:#0000CC;

text-align:center;

text-decoration:none;
display:inline-block;

opacity:1.0;

border-radius:3px;

margin:3px;

font-weight:bold;

Template.php

<?php

session_start();

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

?>

<!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>ABC Company</title>

<link rel="stylesheet" type="text/css" media="all" href="ProjDesign.css">

</head>

<body>

<?php
echo '<div class="wrapper">

<div class="box header">

<img src="Imgs/banner.jpg" width="100%">

</div>

<div class="box sidebar">

<p align="right">REGISTRATION</p>

<a href="NumGen.php">Employee</a><br>

<a href="">User</a>

<p align="right">SEARCH</p>

<a href="Search.php">Search Employee</a>

</div>

<div class="box content">

<table width="100%">

<tr>

<td align="right">You are sign in as


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

</tr>

<tr>

<td>

<img src="Imgs/main.jpg" width="100%">

</td>

</tr>

</table>
</div>

<div class="box footer">footer</div>

</div>';

?>

</body>

</html>
Main.php
Code :

<?php

session_start();

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

?>

<!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>ABC Company</title>

<link rel="stylesheet" type="text/css" media="all" href="ProjDesign.css">

</head>

<body>

<?php

echo '<div class="wrapper">

<div class="box header">

<img src="Imgs/banner.jpg" width="100%">

</div>

<div class="box sidebar">

<p align="right">REGISTRATION</p>

<a href="NumGen.php">Employee</a><br>

<a href="">User</a>

<p align="right">SEARCH</p>

<a href="Search.php">Search Employee</a>

</div>

<div class="box content">

<table width="100%">
<tr>

<td align="right">You are sign in as


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

</tr>

<tr>

<td>

<img src="Imgs/main.jpg" width="100%">

</td>

</tr>

</table>

</div>

<div class="box footer">footer</div>

</div>';

?>

</body>

</html>

Logout.php

<?php

session_start();

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

?>

<!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>
</head>

<body>

<?php

$user=$_SESSION['RName'];

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

if($conn){

$queMax="SELECT MAX(LogSerial) FROM logsch GROUP BY RealName HAVING


RealName='$user' ORDER BY LogSerial DESC LIMIT 1";

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

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

echo 'Awo...';

$val=mysqli_fetch_assoc($data);

$se=$val["MAX(LogSerial)"];

$queUp="UPDATE logsch SET LOUT=(now()) WHERE LogSerial='$se'";

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

header("Location:Login.html");

else{

echo 'Login Schedule is NOT Updated!'.mysqli_error($conn);

else{

echo 'Database is NOT Connected!'.mysqli_error($conn);

}
?>

</body>

</html>

You might also like