You are already running the query you need to achieve this. You just need to get the info from the query.
PHP Code:
<?php
ob_start("ob_gzhandler");
session_start(); // This MUST be at the very top of your pages. It can only come after ob_start() and nothing else.
include('config.php');
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = mysql_real_escape_string($_POST[Customer_Name]);
$password = mysql_real_escape_string($_POST[Password]);
//query
$query = mysql_query("SELECT * FROM customer WHERE Customer_Name='$name' AND Password='$password'");
$query_rows = mysql_num_rows($query);
if($query_rows > 0) {
echo("Successful Login!");
$row = mysql_fetch_assoc($query); // The data from the DB
$_SESSION['cname'] = $name;
$_SESSION['id'] = $row['Customer_ID']; // The customer_id from the DB
//the following code is for redirecting when submit button is pressed
//another alternative is saving the .php file to 'UTF-8 without BOM'
header ("location: logged.php");
} else {
echo("Login Failed!");
}
}
?>
Now you can use $_SESSION['id'] on any other page that has session_start(); at the top of it. Read the comments I put in the script.
Bookmarks