Frederick, I get the error on my authenticate.php page.
It also gives the following error:
Sql error : No Database Selected
Here is the authenticate.php code:
<?php
error_reporting(2047); // 1 = suppress warning messages, 2047 = E_ALL all error messages
session_start(); // initialise session
header("Cache-control: private"); // allow the back button to function
// convert username and password from POST or SESSION
if($POST["username"])
{
$username=$POST["username"];
$password=$POST["password"];
}
elseif($SESSION["username"])
{
$username=$SESSION["username"];
$password=$SESSION["password"];
}
// start and register session variables
session_register("username");
session_register("password");
// connect to database
include("connect.php");
include("banner.php");
// $link = mysql_connect("studb.cms.gre.ac.uk", "hp208", "") or die("Cannot connect to DB!" . mysql_error());
// @mysql_select_db("mdb_hp208") or die("Cannot select DB : " . mysql_error());
// if(isset($POST["submit"])) {
// $sql = "SELECT id, username FROM users WHERE username='" . mysql_real_escape_string($POST["username"]) . "' and pwd = '" . //mysql_real_escape_string($_POST["password"]) . "'";
// $result = mysql_query($sql) or die("Sql error : " . mysql_error());
// check username and password
$sql = "select * from users where username='" . $username . "' and password='" . $password . "'";
$result=mysql_query($sql) or die("Sql error : " . mysql_error());
if(mysql_num_rows($result) == 0) {
print "No such login in the system. Please try again.";
session_destroy();
exit();
}
else{
print "Successfully logged into system.";
//proceed to perform website’s functionality – e.g. present information to the user
}
?>