Login page:

<?php
require_once(‘includes/config.inc.php’);
mysql_connect(DB_HOSTNAME,DB_USERNAME,DB_PASSWORD);
mysql_select_db(DB_DATABASE);
$email=@$_POST[’email’];
$pwd=@$_POST[‘password’];
$url=@$_POST[‘url’];
$query=”select * from customer where email=’$email’ and pwd=’$pwd'”;
$result=mysql_query($query);
if(mysql_num_rows($result) == 1)
{
session_start();
$member = mysql_fetch_assoc($result);
$_SESSION[‘SESS_MEMBER_ID’] = $member[‘custId’];
$_SESSION[‘SESS_NAME’] = $member[‘custName’];
session_write_close();
header(“Location: $url”);

}
else
{
header(“Location: $url”);
echo ‘<script language=”javascript”>fail();</script>’;

}

?>
<script language=”javascript”>

function fail()
{
alert(“Login Credentials are incorrect.”);
//window.location=”http://localhost&lt;?php echo $url; ?>”;
}
function success()
{
alert(“login Successful”);
//window.location=”http://localhost&lt;?php echo $url; ?>”;
}

</script>

 

logout page:

<script language=”javascript”>

function success()
{
window.location=”index.php”;
}
</script>
<?php //error_reporting(0); ?>
<?php
//Start session
session_start();

//Unset the variables stored in session
unset($_SESSION[‘SESS_MEMBER_ID’]);
unset($_SESSION[‘SESS_NAME’]);

session_destroy();
echo ‘<script language=”javascript”>success();</script>’;
?>