dalecosp - I hadn't thought of that, although please don't get me wrong, I wasn't trying to get you to do the work for me, I was simply trying to find an error, and I wasn't sure whether it would be in the same file, there are many so I've posted them below.... and yes, I would like to be a better coder. 😉
This should be the only one needed:
<?
/* Check User Script */
session_start(); // Start Session
include 'db.php';
// Conver to simple variables
$username = $_POST['username'];
$password = $_POST['password'];
if((!$username) || (!$password)){
echo "Please enter ALL of the information! <br />";
include 'login_form.html';
exit();
}
// Convert password to md5 hash
$password = md5($password);
// check if the user info validates the db
$sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' AND activated='1'");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
// Register some session variables!
session_register('username');
$_SESSION['username'] = $username;
session_register('userid');
$_SESSION['userid'] = $userid;
mysql_query("UPDATE users SET last_login=now() WHERE userid='$userid'");
header("Location: login_success.php");
}
} else {
echo "You could not be logged in! Either the username and password do not match or you have not validated your membership!<br />
Please try again!<br />";
include 'login_form.html';
}
?>
Now to reexplain what's happening, it simply does not allow me to login which is a bit of a pain, 😃 so unless IIS doesn't support sessions it's a problem with the code, and I've re-read it for the past few hours and found nothing obvious that's wrong with it.
Thanks,
Chris