i'm not able to figure out any result out of thsi page or rather get "parse errors" like " undefined T-Variable ...... UserID .... am using windows o/s configured fro sapi support .....apache webserver 1.3. ..... mysql....... plz check the folowing code n pass on comments ASAP
#!/usr/local/bin/php
<?php
//session_start();
//$adminName = "root";
//$password = "pass";
$serverName = "localhost";
$dbName = "phplogin";
$sql = "SELECT * FROM logins WHERE UserID = '$UID'";
function outError($errMsg){
//10
printf("%s <BR>\n", $errMsg);
}
if($UID != ""){
if(!($conn = mysql_connect($serverName))){
outError(sprintf("Error connecting to host %s, by user %s", $serverName));
exit();
}
//20
if(!mysql_select_db($dbName, $conn)){
outError(sprintf("Error selecting %s database", $dbName));
outError(sprintf("The error is: %d %s", mysql_errno($conn), mysql_error($conn)));
exit();
}
if(!($result = @($sql, $conn))){
outError(sprintf("Error executing %s statement", $sql));
outError(sprintf("The error is: %d %s", mysql_errno($conn), mysql_error($conn)));
//30
exit();
} else {
if(mysql_num_rows($result) != 0)
{
if(($row = mysql_fetch_array($result)) && ($Password == $row["Password"] && $Password != ""))
//40
{
$valUserID = $UserID;
session_register("valUserID");
mysql_close($conn);
header("location:http://127.0.0.1/phpfiles/1.php");
exit();
}
else
//50
{
//invalid password handling
header("location:http://127.0.0.1/phpfiles/login.html");
exit();
}
}
else {
//invalid userid handling
header("location:http://127.0.0.1/phpfiles/2.php");
//60
exit();
}
}
mysql_close($conn);
}
?>
<HEAD>
<TITLE>Login Page</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff" TEXT="#000080" onLoad="document.myForm.UserID.focus();">
<H3>Please login:</H3>
<HR>
<TABLE>
<FORM NAME="myForm" METHOD="post" ACTION="login.php">
<TR><TD ALIGN="right"><B>UserID</B><TD><INPUT TYPE="text" NAME="UID" SIZE="40">
<TR><TD ALIGN="right"><B>Password</B><TD><INPUT TYPE="password" NAME="Password" SIZE="40">
<TR><TD COLSPAN="2" ALIGN="center"><INPUT TYPE="Submit" VALUE="Login">
</FORM>
</TABLE>
</BODY>