The below login script does work. The form does not seem to be
submitting. I keep getting the username and password fields. The only
errors I get are notices that email and password and undefined
indexes.
Here's the login script:
<?php
session_start();
// includes
include_once ("includes/common.php");
include_once ("includes/db_vars.inc");
//check to see isLoggedIn is True
if (!isset($_SESSION["isLoggedIn"])) {
?>
<!-- LOGIN FORM -->
<form method=post action="<?echo $_SERVER['PHP_SELF']?>">
<table cellpadding=2 cellspacing=0 border=0>
<td>Username:</td><td><input type="text" name="email"
size=10></td><tr>
<td>Password:</td><td><input type="password" name="password"
size=10></td><tr>
<td> </td><td><input type="submit" name="submit" value="Log
In"></td>
</table></form>
<?php
//connect to database
dbConnect('crc1');
$email = $_POST['email'];
$password = $_POST['password'];
$sql = "SELECT * FROM crc1.tblusers WHERE emailaddress = '$email' AND
password = md5('$password')";
echo $sql;
$result = mysql_query($sql) or die ("Error in query: $sql. " .
mysql_error());
while ($row=mysql_fetch_array($result)) {
if (mysql_num_rows($result)!= False) {
$isLoggedIn = TRUE;
session_register($email);
session_register($password);
session_register($isLoggedIn);
header('location: http://localhost/app/mycrc/mycrc.php');
}// end if
}//end if
}else{
//debugging
echo ''.$_POST['email'].' <br/>';
echo ''.$_POST['password'].'<br/>';
echo 'Could not log you in.<br/>';
print_r ($_SESSION);
}//end if
?>
I'd appreciate it if someone could give me some pointers.