Jump to content

Beginner learning sessions


mastershake22

Recommended Posts

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

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/]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.