Page 1 of 1
wonky session
Posted: Tue Sep 24, 2002 4:43 am
by Coco
ok i created a simple sessions login script for my site.... all was fine last night, worked beautifully...
now i come on this morning, change something unrelated and test it...
bear in mind that i havent logged into the script all day...
session variables are already present, im already logged in.

and the pc has been switched off overnight

whats going on?
(i was using globals ($HTTP_SESSION_VARS) and i tried the non global ones ($_SESSION) and it didnt work at all)
Posted: Tue Sep 24, 2002 4:45 am
by Coco
this is the code:
Code: Select all
<?php
include ('DBdet.php');
session_start();
if(empty($HTTP_SESSION_VARSї'user'])){
if($HTTP_POST_VARSї'user']){
$db=mysql_connect(HOST, USER, PASS);
if (!$db)
die ("I can't connect!");
$ok=mysql_select_db(DB);
if (!$ok)
die ("I can't connect to the DB!");
$result = mysql_query("SELECT COUNT(*) AS numfound FROM Players WHERE user='{$HTTP_POST_VARSї'user']}' AND pass='{$HTTP_POST_VARSї'pass']}'");
$result1 = mysql_fetch_array($result);
mysql_close();
if($result1ї'numfound'] >= 1){
$user = $HTTP_SESSION_VARSї'user'];
session_register('user');
header("Location: http://burtonroad.coolfreepages.com/main.php");
exit;
}
else
{ header("Location: http://burtonroad.coolfreepages.com/main.php");
exit;
}
}//close if($POSTї'user'])
else
{
include ('top.php');?>
Please Login:
<table border=1 cellpadding=3 cellspacing=0><tr><td>
<form method=POST ACTION="<?= $PHP_SELF ?>" target="main">
<table border=0 cellpadding=3 cellspacing=0>
<tr><td align=left valign=top>Username:</td>
<td align=left><input type=text size=15 name=user></td></tr>
<tr><td align=left valign=top>Password:</td>
<td align=left><input type=password size=15 name=pass></td></tr>
<tr><td></td><td align=left valign=top><input type=submit name=submit value="Login"></td></tr></table>
</form></td></tr></table>
<?php
}}else{// close else(login form), close if(empty)
include ('top.php');?>
//page content
there are no error messages