Its still not working, and i think its still the session.
Instead of redirecting back to the login.php ive got it to output an error message if the session is not equal to true. it does this and displays a sessionID in the address bar, as below:-
http://localhost/index.php?sid=e25fc...b9834d76ffcbfa
does that mean a session has been made?
it still shows me the error message though! not the secure content!
is there a different way i can do this? like totally start a fresh?
or could you each page ive got?
its really stressfull!!
ill post the code ive got so far AGAIN!!
login.php
contains the username and password which are checked against the database and put into variables $username and $password once submitted to the logincheck.php
logincheck.php
<?php
session_start();
$dbc = mysql_connect('localhost', 'Ashleek007', '') or die ('Could not connect to MySQL :' .mysql_error());
mysql_select_db('login') or die('Could not connect to database :' .mysql_error());
$username = $_POST['username'];
$password = $_POST['password'];
$query = "Select * From userlogin Where USERNAME = '$username' And PASSWORD = '$password'";
$result = mysql_query($query) or die(mysql_error());
if(mysql_num_rows($result) == 1)
{
$_SESSION['logged_in'] = true;//doesnt seem to set this session?
header('Location: index.php?sid='.session_id());
}
else
{
$_SESSION['logged_in'] = false;
echo "Incorrect Username/password";
//it still checks the username and password correctly though
}
mysql_close();
?>
index.php
<?php
session_start();
if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] == true)
{
?> <a href="logout.php">logout </a><?PHP
}
else
{
echo 'error';
}
?>
all it does is output the error from the else statement above! its like it doesnt know about the session ive set in the logincheck.php ive even tried just if(isset blahblah....) without checking the value and it still throws out the error?!
do i need to tell the thing that ive used sessions or that im goin to use sessions?
im feeling grim
thanks for your persistance with this pain in ur ass!
ASH