dominic600 Posted August 8, 2011 Share Posted August 8, 2011 okay, so the problem I am having is that when i log in, i shouldnt be able to keep logging it and it keep telling me im loged in. like it should be that when i log in and im already loged in that it should read out "you are already loged in" but it does not do that. it was working correctly 2 night ago. heres the login.php code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>1st Gen Cummins Blog | Login</title> <link href='main.css' rel='stylesheet' type="text/css"></link> </head> <body> <div id='header'><div id='headercnt'>1990 Dodge Cummins Turbo Diesel</div><div> <div id='content'> <hr /> <table border=0 width=1000 height=40> <TR height=40> <TD colspan="2"><center>Youtube | Contact Me | Pictures | <a href='register.php'>Register</a> </center></TD> </TR> </table> <hr /> <?php $form = "<form action='login.php' method='post'> <center><table> <tr> <td>Username:</td> <td><input type='text' name='username' class='textbox'></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password' class='textbox'></td> </tr> <tr> <td></td> <td><input type ='submit' name='loginbtn' value='Login' class='button'></td> </tr> </table></center> </form>"; if ($_POST['loginbtn']){ $username = strip_tags($_POST['username']); $password = strip_tags($_POST['password']); if($username && $password){ require("scripts/connect.php"); $pass = md5(md5($password)); $query = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$pass'") or die(mysql_error()); $numrows = mysql_num_rows($query); if ($numrows == 1){ $row = mysql_fetch_assoc($query); $dbid = $row['id']; $dbuser = $row['username']; $date = ("F d, Y"); mysql_query("UDATE users SET last_login='$date' WHERE id='$dbid'"); $_SESSION['user'] = $dbuser; $_SESSION['userid'] = $dbid; echo "You are now loged in.<a href='index.php'> Click here </a>to return Home."; } else echo "Your Username and/or Password are incorrect."; } else echo "You did not fill in the correct fields."; } else echo "$form"; ?> <hr /> </div> <div id='footer'></div> </body> </html> Quote Link to comment Share on other sites More sharing options...
phpSensei Posted August 8, 2011 Share Posted August 8, 2011 Hi Dominic, This is simply a login form, I don't see how you are checking if the user is logged in or not. Quote Link to comment Share on other sites More sharing options...
dominic600 Posted August 8, 2011 Author Share Posted August 8, 2011 Yes, I didnt relize that, i just relized my profile.php file was not in the folder and thats waht i have to read the login. lol sorry, for the waste of time i caused Quote Link to comment Share on other sites More sharing options...
phpSensei Posted August 8, 2011 Share Posted August 8, 2011 You havn't caused a waste of time for anybody my friend. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.