Hello,
I really need this Login Script completed, and I haven't got it working in the past 5 days, and I'm getting very frustrated!!!
My problems are:
A) As far as I'm aware, the SESSION doesn't get set
B) When I login with the correct details, all that really happens is the page gets refreshed, I don't get take to info.php or anything!
PLEASE HELP!
Code:
<?php
// start of login script
// database information
$dbhost = "localhost";
$dbname = "";
$dbuser = "";
$dbpass = "";
// connect to database
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
// start session
session_start();
// retrieve form input
$username = htmlentities(mysql_real_escape_string($_POST['username']));
$password = (md5($_POST['password']));
// query the database
$query = "SELECT * from users WHERE username='$username' and password='$password'";
$result = mysql_query($query);
$aAssoc = mysql_fetch_assoc($result);
$rank = $qAssoc['rank'];
if(mysql_num_rows($result) === 0 || $aAssoc['rank'] == 0){
include('incorrect.php');
}else{
if($rank = 1){
$SESSION['registered'] = true;
}
if($rank = 2){
$SESSION['member'] = true;
}
if($rank = 3){
$SESSION['moderator'] = true;
}
if($rank = 4){
$SESSION['admin'] = true;
}
header("Location: info.php");
}
// end of script
?>