Creating a session user login php
Posted
by
user2419393
on Stack Overflow
See other posts from Stack Overflow
or by user2419393
Published on 2013-11-03T21:44:36Z
Indexed on
2013/11/03
21:54 UTC
Read the original article
Hit count: 184
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);
?>
© Stack Overflow or respective owner