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! Link to comment https://forums.phpfreaks.com/topic/231424-beginner-learning-sessions/ 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 Link to comment https://forums.phpfreaks.com/topic/231424-beginner-learning-sessions/#findComment-1191008 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/] Link to comment https://forums.phpfreaks.com/topic/231424-beginner-learning-sessions/#findComment-1191011 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.