PHP session
Posted: Mon Jun 16, 2008 2:33 pm
I am new to using php and session varaibles and im having problems using a session accross multiple pages
index
<?php
include("db.php");
session_start();
if(!isset($_session['user'])){
$_session['user'] =0;
}
else
{
echo 'logged in';
}
?>
login action page
<?php
session_start();
include("db.php");
$username = $_POST ['uname'];
$password = $_POST ['p'];
$login = @mysql_query("select * from users where username='$username'");
while($row =mysql_fetch_array($login))
{
$_session['user']=$row['id'];
//echo $_session['user'];
header('location:blah blah');
}
this returns to a page but the session is still zero and i am stuck finding a solution
index
<?php
include("db.php");
session_start();
if(!isset($_session['user'])){
$_session['user'] =0;
}
else
{
echo 'logged in';
}
?>
login action page
<?php
session_start();
include("db.php");
$username = $_POST ['uname'];
$password = $_POST ['p'];
$login = @mysql_query("select * from users where username='$username'");
while($row =mysql_fetch_array($login))
{
$_session['user']=$row['id'];
//echo $_session['user'];
header('location:blah blah');
}
this returns to a page but the session is still zero and i am stuck finding a solution