i have some code that works to a point, but doesn’t quite do exactly what i am after.
when the user enters the incorrect details into my login form i need it to display a message saying sorry you are not authorised to view this page. at present i just get a white screen.
[php]<?
import_request_variables(‘p’);
if ((!$username) || (!$password)) {
//header("Location: ./show_login.html");
print("<HTML>");
print("<HEAD>");
print("<TITLE>Error</TITLE>");
print("</HEAD>");
print("<BODY>");
print("User name = $username password = $password n");
print("</BODY>");
print("</HTML>");
exit;
}
$db_name = “_db”;
$table_name = “tablename”;
$connection = @mysql_connect(“localhost”, “username”, “me”)
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=”$username" AND password=password("$password")";
$result = mysql_query($sql)
or die ("Can't execute query.");
$num=0;
$num = mysql_numrows($result);
if ($num != 0) {
header("Location:http://www.ilt.bridgwater.ac.uk/~staua/contactslist.php");
exit;
} else
{ $msg = "
Sorry, you’re Not authorized!
";exit;
}
?>
Secret Area <? echo "$msg"; ?>[/php]
please help
Andy