|
Posted by Lee David on 08/06/05 07:11
I am using code to validate a user against a database and then if they are
valid, redirecting the page to the working page. I copied the code from
another application I have where it works, but it doesn't work here. What
happens is if the Header is included, a blank page appears with the URL of
the validation page (SQL_User_Validate.php). If the Header is commented
out, the form appears and you can enter the data and see the results, but
not with a redirection.
Most likely is I've made an obvious (to everyone else) mistake that you will
see in 20 seconds. And that I have not seen in the past hour of working on
it. Here is the code (to the Header):
<?php
include("SQL_A_Connect.inc");
$name_table = "User";
// error_reporting(E_ALL & ~E_NOTICES);
error_reporting(E_ALL);
// testing *************************
$testcode0 = "valid: " . isset($_POST['uservalid']);
$testcode1 = "";
$testcode2 = "";
if ((isset($_POST['uservalid'])) && ($_POST['uservalid'] == "yes"))
{
$frmID = $_POST["frmID"];
$frmPWD = $_POST["frmPWD"];
$sql_code = "SELECT Password, Level FROM " . $name_table . " ";
$sql_code .= "WHERE UserID = '$frmID'";
// testing only ***********************
$testcode1 = "query: " . $sql_code;
$sql_result = mysql_query($sql_code,$name_connect) or die(mysql_error());
$output = mysql_fetch_array($sql_result);
$sqlPWD = $output["Password"];
$sqlLVL = $output["Level"];
// testing only **************************
$testcode2 = "sql pwd: '" . $sqlPWD . "'<br>sql lvl: '" . $sqlLVL .
"'<br>rows: '" . mysql_num_rows($sql_result) . "'<br>post pwd: '" . $frmPWD
.. "'<br>post id: '" . $frmID . "'<br>";
$hold = time() + 60 * 60 * 24 * 180;
if ($sqlPWD == $frmPWD)
{
// validated user - write cookie and continue
setcookie("user", $frmID, $hold);
setcookie("level", $sqlLVL, $hold);
setcookie("authorized", "yes", $hold);
// header("Location: ../SQL_User.php);
}
else
{
setcookie("user", "guest", $hold);
setcookie("level", "0", $hold);
setcookie("authorized", "no", $hold);
// header("Location: ../SQL_User_Validate.php);
}
}
?>
Any ideas?
[Back to original message]
|