Wierd problem - members have to log in twice

software development

#1

Greetings,

Some of my members are complaining that they have to log into my site twice.

When they log in the first time, they get the “login failed” message. They then press the back button and log in once again and it always works the second time.

Here is my login page code (PHP and the HTML form). I’m sure it is probably something really simple but I am not catching it. Let me know if you see something:

[php]

<?php include("connection.php"); mysql_select_db("database"); session_start(); if(isset($_POST['login'])){ $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $tUnixTime = time(); $sGMTMySqlString = gmdate("Y-m-d H:i:s", $tUnixTime); if (!$username || !$password) { print "Please fill out all fields."; exit; } $logres = mysql_num_rows(mysql_query("SELECT * FROM members WHERE username = '$username' and password = '$password'")); if ($logres <= 0) { print "Login failed. If you have not already, please signup. Otherwise, check your spelling and login again."; exit; } else { session_start(); session_register('username'); $_SESSION['username'] = $username; if (isset($_SESSION)) { echo'You are now logging in'; mysql_query("UPDATE members SET activity = '$sGMTMySqlString' WHERE username = '$username'"); } else { echo "You are not logged in!"; } echo''; exit; } } ?> Login Page
<?php include("header.php"); ?> <?php include("sidebar.php"); ?>

Use the form below to log in:

Member Login
Username :
Password :
   
Forgot your Password or Username? Click Here

<?php include("footer.php"); ?>
[/php]

#2

Thanks for looking at this, but I think I have it fixed now.