
September 23rd, 2004, 12:43 AM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 3
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Session not registering
I have a simple login script running.. It queries the DB and then redirects the user to the their selected homepage. What I found was that it wasn't too secure, cause if the user knew the URL they could just go direct and lose some features. Solution was to create a Session to see if they logged in our not... Im still logging in and redirecting correctly though when I do the SESSION check it is not finding a match and echoing the user name
below extract from my login script
PHP Code:
if ($u && $p) {// If everything is OK, Lets Query the DB
$sql = "SELECT Client, HomePage FROM details WHERE uid='$u' AND password='$p'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result, MYSQL_NUM);
$homepage = $row[1];
if ($row) {
//start the session, register the values & redirect
$_SESSION['Client'] = $row[0];
Extract from my user page, where I check if the session has been registered or not. This is not giving me the Client Name
PHP Code:
//Welcome the user by name if they are logged in
echo '<h1>Welcome';
if (isset($_SESSION['Client'])) {
echo ", {$_SESSION['Client']}!";
}
echo('</h1>');
?>
in the subsequent pages I have create a file header.htm
which has the code
<?php
session_start();
?>
and the header code is called as an include
require_once('../header.htm');
Where I should I be looking for answers?
|