<?php
session_start();
error_reporting(E_ALL ^ E_DEPRECATED);
$host = "localhost";
$user = "root";
$pass = "";
$db = "testing";
mysql_connect($host, $user, $pass);
mysql_select_db($db);
if (isset($_POST['loginID'])) {
$loginID = $_POST['loginID'];
$password = $_POST['password'];
$sql = "SELECT * FROM user WHERE loginID='".$loginID."' AND password='".$password."' LIMIT 1";
$res = mysql_query($sql);
if (mysql_num_rows($res) == 1) {
header("Location:homepage.php");
$_SESSION['loginID'] = $loginID;
} else {
header("Location:login.php");die;
}
}
?>
I want to pass the username in a session, to show the username in homepage.php
, but it didn't work when I tried to do so. What is wrong, and how can I make it work?