log in authntication
Posted: Fri Sep 04, 2009 12:25 pm
Hi.
Im having trouble gettin my log in to authenticate.
I've been going over it racking my head and i cant see why.
I have the log in form in HTML which i cant see there would be a problem there
The problem is in the authenticate.php
Please excuse my sloppy indentation.
The problem is after logging in the page just goes to a blank screen.
Can anyone see why?
I appreciate all help.
Im having trouble gettin my log in to authenticate.
I've been going over it racking my head and i cant see why.
I have the log in form in HTML which i cant see there would be a problem there
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="Fred!" />
<title>Log in</title>
</head>
<body></body>
<FONT FACE="Arial, Helvetica, Geneva">
Please enter your user log in details here...<br><br>
<form action = "authenticate.php" method = "post">
Username: <br>
<input type = "text" name = "username">
<br><br>
Password: <br>
<input type = "password" name = "password">
<br><br>
<input type = "submit" value = "Log In">
</form>
</font>
</body>
</html>
Code: Select all
<?php
//include("header.php");
//can we use mysql?
if(!function_exists('mysql_connect')) die("MySQL extension not enabled");
//connect to mysql server
$conn =@mysql_pconnect('************', '*********', '*******') or die(mysql_error());
mysql_select_db('b11_4059953_db1') or die(mysql_error());
//find our script name
$script = $_SERVER['PHP_SELF'];
$referer = $_SERVER ['HTTP_REFERER']
$username = (isset($_POST['username'])) ? mysql_real_escape_string($_POST['username']) : '';
$password = (isset($_POST['password'])) ? mysql_real_escape_string($_POST['password']) : '';
//if either form is empty return to login
if ((!$username) or(!$password))
{
header ("Location:$referer"); exit();
}
//create query
$sql="select * from users where username =\"$username\" and password =\"$password\"";
//execute the query
$rs = mysql_query ($sql, $conn) or die ("could not execute query")
//get number of rows
$num = mysql_numrows ( $rs );
//log in if match
if ($num !=0)
{
$msg = "Welcome $username - you are logged in";
}
else
{
header ("Location:$referer"); exit();
}
?>
<html> <head> <title> Logged in </title> </head>
<body>
<?php echo ( $msg );
?>
</body>
</html>
Please excuse my sloppy indentation.
The problem is after logging in the page just goes to a blank screen.
Can anyone see why?
I appreciate all help.