mastershake22 Posted March 22, 2011 Share Posted March 22, 2011 HI, I'm new to PHP and I'm trying to learn what sessions are and how they work. I'm working on a login page, I have a table in mysql for sessions, and I have a table with users that includes an email address and password. I just want to query the db to see if there is a user with that email, check the password, and start a session. Every "tutorial" i've looked at fails to answer how the session gets stored in the db, what variable I should set the session at to pull a user's information, and how to use that session to actually echo the information. I'm really frustrated and lost so if anyone knows the correct code or can explain the questions I mentioned above I would appreciate it alot. Thanks! Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 22, 2011 Share Posted March 22, 2011 Please post the code you have between tags. Ken Quote Link to comment Share on other sites More sharing options...
mastershake22 Posted March 22, 2011 Author Share Posted March 22, 2011 include 'config.php'; $result=mysql_query("SELECT * FROM persons WHERE email='$_POST[email]' AND password='$_POST[password]', $db_name"); //check that at least one row was returned $rowCheck = mysql_num_rows($result); if($rowCheck > 0){ $row = mysql_fetch_array($result); header( "Location: profile.php" ); } else { //if nothing is returned by the query, unsuccessful login code goes here... echo 'Incorrect login name or password. Please try again.'; } ?> [code/] 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.