Hi all,
I tried some sessions tutorial and had a play around with my own file, thus:
<?php // index.php
session_start();
include_once './inc/db.inc';
$uid = isset($_POST['EMail']) ? $_POST['EMail'] : $_SESSION['EMail'];
$pwd = isset($_POST['Password']) ? $_POST['Password'] : $_SESSION['Password'];
if(!isset($_SESSION['Email'])) {
$_SESSION['Email'] = '';
}
if(!isset($_POST['SUBMITFORM'])) {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>...
</html>
<?php
}
else {
$_SESSION['Email'] = (string) $_POST['Email'];
$_SESSION['Password'] = (string) $_POST['Password'];
}
dbConnect("pa");
$sql = "SELECT * FROM members WHERE
mEmail = '$EMail' AND mPassword = PASSWORD('$Password')";
$result = mysql_query($sql);
if (!$result) {
error('A database error occurred while checking your '.
'login details.\\nIfhis error persists, please '.
'contact [email]you@example.com[/email].');
}
if (mysql_num_rows($result) == 0) {
unset($_SESSION['EMail']);
?>
<!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>
<title> Access Denied </title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1" />
</head>
<body>
<h1> Access Denied </h1>
<p>Your user ID or password is incorrect, or you are not a
registered user on this site. To try logging in again, click
<a href="<?=$_SERVER['PHP_SELF']?>">here</a>. To register for instant
access, click <a href="join.php">here</a>.</p>
</body>
</html>
<?php
exit;
}
?>
However, at the bottom of the page, it keeps printing the 'Access Denied' part.
Any ideas on what I am doing wrong?
Thanks.
Mak 🙂