I have a log in script, when the form redirects it is simply showing a blank screen, any ideas? I am quite new to PHP so any comments on the script in general would be great.
Many thanks for your help!
<?php
session_start(); //must call session_start before using any $_SESSION variables
$username = $_POST['username'];
$password = $_POST['password'];
//connect to the database here
require_once('../Connections/PropSuite.php');
mysql_select_db($database_PropSuite, $PropSuite);
$username = mysql_real_escape_string($username);
$query = "SELECT password, salt
FROM users
WHERE username = '$username';";
$result = mysql_query($query);
if(mysql_num_rows($result) < 1) //no such user exists
{
header('Location: index.php');
die();
}
$userData = mysql_fetch_array($result, MYSQL_ASSOC);
$hash = hash('sha256', $userData['salt'] . hash('sha256', $password) );
if($hash != $userData['password']) //incorrect password
{
header('Location: index.php');
die();
}
else
{
validateUser(); //sets the session data for this user
}
//redirect to another page or display "login success" message
?>
I think you are missing the redirect unless you have it in the validateUser() function.
If not you can do either:
or..