Use this code and run a test. Then post the text displayed
<?php
include("config.php");
// connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass)
or die ("Could not connect to mysql because ".mysql_error());
// select the database
mysql_select_db($database)
or die ("Could not select database because ".mysql_error());
include ("function.php");
//$match = "select id from $table where username = '".$_POST['username']."'
//and password = '".hashPW($_POST['password'],$_POST['username'])."';";
//Test Query
$match = "select password from $table where username = '".$_POST['username']."'";
$qry = mysql_query($match)
or die ("Could not match data because ".mysql_error());
//----BEGIN TEST CODE
$result = mysql_fetch_assoc($qry);
echo "QUERY: {$match}<br />
POSTED VALUES:<br />
- Username: {$_POST['username']}<br />
- Password: {$_POST['password']}<br />
- Hashed Password: " . hashPW($_POST['password'], $_POST['username']) . "<br />";
echo "Database Password: {$_result['password']}";
exit();
//-----END TEST CODE
$num_rows = mysql_num_rows($qry);
if ($num_rows <= 0) {
echo "Sorry, there is no username, {$_POST['username']}, with the specified password.<br/>";
echo "<a href=user_login.php>Try again</a>";
exit;
}
else {
setcookie("loggedin", "TRUE", time()+(3600 * 24));
setcookie("mysite_username", "{$_POST['username']}");
header('Location:http://mythscape.freezoka.com/');
die();
}
?>