The user table is setup as:
ID | Name | Email | Password
and they login with:
Email | Password
I’m wondering how I can display their ‘Name’ when they login with their e-mail. What I have so far that works with email is:
session_start();
if (!isset($_SESSION['email'])) {
header('location: ');
}
include_once('config.php');
$email = $_SESSION['email'];
<!doctype html>
<body>
<p><?php echo $email; ?>
and that works, but when I try something like
$sql = "SELECT name FROM $table WHERE email='$_SESSION["email"]'";
$result = mysql_query($sql);
<!doctype html>
<body>
<p><?php echo $result; ?></p>
that doesn’t work.
Any help is appreciated
mysql_query()only returns a resource, this needs to be passed tomysql_fetch_array()to deal with the returned records; http://php.net/manual/en/function.mysql-query.php has some examples