Hi All,
when signing in and after being passed from the loginscript.php to the search page, it auto sends the user back to index.php. It shouldn't b doing this, as I thought I had set my sessions up correctly. What have I missed.?
loginscript.php:
<?php
$db = mysql_connect("localhost", "root", "grunger");
if (!$db) {
echo "no connection because " . mysql_error();
exit;
}
mysql_select_db("status", $db);
$username = $_POST["username"];
$password = $_POST["password"];
$result = mysql_query("SELECT customer_id FROM Customers WHERE customer_username = '$username' AND customer_password = '$password'") or die (mysql_error());
$myrow = mysql_fetch_row($result);
$customer_id = $myrow[0];
$_SESSION['customer_id'] = $customer_id;
?>
<script language="JavaScript1.1">
function doRedirect()
{
window.location.href = "search.php";
}
</script>
</head>
<body onLoad="doRedirect ()">
search.php:
<?php
session_start();
if (!$_SESSION['customer_id']) {
header("Location: index.php");
}
?>
EDIT: Hold the fort...seems I'd forgotten to add this,
<?php
session_start();
?>
to the top of loginscript.php...cheers.