In: Computer Science
Use PHP, javascript and a little bit of Html
More focus on php
Create a logout page (for patients) in hotel management.
Please provide the screenshot of the output too (logout page).
Hint: the logout page should include like this thanks for visting etcetera.
Thanks in advance
CONFIGURATION
<?php
$hostname='localhost';
$user = 'root';
$password = '';
$mysql_database = 'user';
$db = mysql_connect($hostname, $user,
$password,$mysql_database);
mysql_select_db("user", $db);
?>
HOME PAGE
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Logout page</title>
</head>
<body>
<h1>Welcome
<?php
session_start();
$login_session=$_SESSION['login_user'];
echo $login_session;?></h1>
<a href="logout.php"> Logout </a>
</body>
</html>
LOGIN PAGE
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Logout page</title>
</head>
<body>
<table
width="300" border="0" align="center" cellpadding="0"
cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="" method="post">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1"
bgcolor="#FFFFFF">
<tr>
<td colspan="3" align="center"><strong>Thankyou for
your visit </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="username" type="text"
id="username"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="password" type="password"
id="password"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="submit"
value="Logout">
<input type="reset" name="reset"
value="reset"></td>
</form>
</tr>
</table>
</td>
</tr>
</table>
<?php
if (isset($_POST['submit']))
{
include("config.php");
session_start();
$username=$_POST['username'];
$password=$_POST['password'];
$_SESSION['login_user']=$username;
$query = mysql_query("SELECT username FROM login WHERE
username='$username' and
password='$password'");
if
(mysql_num_rows($query) != 0)
{
echo
"<script language='javascript' type='text/javascript'>
location.href='home.php' </script>";
}
else
{
echo "<script type='text/javascript'>alert('User Name Or
Password Invalid!')</script>";
}
}
?>
</article>
</main>
</div>
</div>
</div>
</body>
</html>
LOGOUT PAGE
<?php
session_start();
if(session_destroy())
{
header("Location: login.php");
}
?>
SQL TEXT PAGE
CREATE TABLE IF
NOT EXISTS `login` (
`user_id` int(11) NOT NULL auto_increment,
`username` varchar(30) NOT NULL,
`password` varchar(30) NOT NULL,
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6
;
OUTPUT
PAGE