Login Script
| From: | Necro | Date: | Fri, 21 Dec 2001 12:39:38 +0000 |
| Subject: | Login Script | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-78448@lists.php.net to get a copy of this message | ||
Lo all,
I am trying to get the following script to work..
<?
if ($HTTP_POST_VARS["action"] == 1)
{
checklogin($HTTP_POST_VARS["user_name"], $HTTP_POST_VARS["password"]);
exit;
}
function checklogin($user, $pass)
{
$sid (login($user, $pass));
if ($sid != -1)
{
header("Location: http://localhost/hq.php?sid=$sid");
}
else
{
header("Location: http://localhost/error.php");
}
}
function login($user, $pass)
{
$db = "zoner2";
$SQL = "SELECT * FROM users WHERE user_name='".$user."' AND
password='".$pass."'";
$connection = db_connect();
$query = mysql_db_query($db, $SQL, $connection);
if (mysql_num_rows($query) != 1)
{
return -1;
}
$row = mysql_fetch_array($query);
$user_id = $row["user_id"];
$sid = md5("blah blah".$user_id.$time());
$remip = REMOTE_ADDR();
$ttime = date("YmdHis");
$SQL2 = " INSERT INTO details ";
$SQL2 = $SQL2 . " (user_id, sid, ttime, remip) VALUES ";
$SQL2 = $SQL2 . "
('$user_id','$sid','$ttime','$remip') ";
#######
$result2 = mysql_db_query($db,"$SQL2",$connection);
if (!$result2) { echo("ERROR: " . mysql_error() . "\n$SQL\n");
mysql_close($cid); exit; }
#######
SetCookie("TheLoginCookie", "$user_id:$sid:$ip", time()+3600);
return $sid;
}
?>
But every time I open the login page and try to login I get the following
error.
Fatal error: Call to undefined function: () in d:\htdocs\web\login1.inc on
line 10
Can anyone explain why this is??
Thankyou.
Andrew