Creating a session user login php
- by user2419393
I'm stuck on how to create a session for a user who logs in. I got the part of checking to make sure the log in information corresponds with the database information, but is stuck on how to take the email address and store into a session. Here is my php code below.
<?php include '../View/header.php';
session_start();
require('../model/database.php');
$email = $_POST['username'];
$password = $_POST['password'];
$sql = "SELECT emailAddress FROM customers WHERE emailAddress ='$email' AND password = '$password'";
$result = mysql_query($sql, $db);
if (!$result) {
echo "DB Error, could not query the database\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
while ($row = mysql_fetch_assoc($result)) {
echo $row['emailAddress'];
}
mysql_free_result($result);
?>