wonky session

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

wonky session

Post 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.
:cry:
and the pc has been switched off overnight
:cry:
whats going on?


(i was using globals ($HTTP_SESSION_VARS) and i tried the non global ones ($_SESSION) and it didnt work at all)
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post by Coco »

this is the code:

Code: Select all

<?php
include ('DBdet.php');

session_start();

if(empty($HTTP_SESSION_VARS&#1111;'user']))&#123;
if($HTTP_POST_VARS&#1111;'user'])&#123;
$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='&#123;$HTTP_POST_VARS&#1111;'user']&#125;' AND pass='&#123;$HTTP_POST_VARS&#1111;'pass']&#125;'");
$result1 = mysql_fetch_array($result);
mysql_close();
if($result1&#1111;'numfound'] >= 1)&#123;
	$user = $HTTP_SESSION_VARS&#1111;'user'];
	session_register('user');
	header("Location: http://burtonroad.coolfreepages.com/main.php");
	exit;
	&#125;
else
&#123;	header("Location: http://burtonroad.coolfreepages.com/main.php");
	exit;
	&#125;	
&#125;//close if($POST&#1111;'user'])
else
&#123;
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
&#125;&#125;else&#123;// close else(login form), close if(empty)
include ('top.php');?>
//page content
there are no error messages
Post Reply