Hello out there -
This thing is driving me nuts. Brand newbie. I want to check data entered in a form against mysql database. Connection is fine, but this code will not return valid results. It either keeps showing what's in the header, or if I change the word "password" in the $sql string to "l_name", it says can't execute. Help please!!!
<?
if ((!$f_name) || (!$l_name)) {
header("Location: http://www.mydomain.com/login2.htm");
exit;
}
$db_name = "mydbname";
$table_name = "dbname";
$connection = @mysql_connect("mysql.mydomain.com", "user", "password")
or die("Couldn't connect.");
$db = mysql_select_db($db_name, $connection)
or die("Couldn't select database.");
$sql = "SELECT * FROM $table_name
WHERE username = \"$f_name\" AND password = password(\"$l_name\")
";
$result = mysql_query($sql)
or die ("Can't execute query.");
$num = mysql_numrows($result);
if ($num != 0) {
$msg = "<P>Enter the gates of heaven...</p>";
} else {
header("Location: http://www.mydomain.com/nope.htm");
exit;
}
?>
<HEAD>
<TITLE>Welcome To Secret Area</TITLE>
</HEAD>
<BODY>
<? echo "$msg"; ?>
</BODY>
Thanks oh so much.