problem...urgent~

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
kevin7
Forum Commoner
Posts: 96
Joined: Fri May 21, 2004 6:54 am

problem...urgent~

Post by kevin7 »

i doin my college project...

it was a system for sales...
before it uploaded into my web hosting... everything work perfectly~
i can login, add customer everything w/o any problems..

after that, i upload it into my web hosting... but, the problem was occured!!! it was a nightmare... databasse login all is correct...

then i login... i can login at the first time.. everything work fine.. but suddenly an acccess denied message comes out~ and i can't login anymore... but sometimes can login... aisk...

my computer using mysql 3.0++ and my web hosting using mysql 4.0.18... is that a problem? i'm using session id...

gosh~~~ how~~
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

umm.. show us some code
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

different versoins of php?
there could be some config problems with sessions
kevin7
Forum Commoner
Posts: 96
Joined: Fri May 21, 2004 6:54 am

Post by kevin7 »

http://www.the-kevin.org/mobilecore/login.php

staff id : 1000
password : kevin7

.... try login and hanging around...
kevin7
Forum Commoner
Posts: 96
Joined: Fri May 21, 2004 6:54 am

Post by kevin7 »

how can i config session in the server?
kevin7
Forum Commoner
Posts: 96
Joined: Fri May 21, 2004 6:54 am

Post by kevin7 »

i think it was a session id problem...
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

i did, i was able to go between all the pages multiple times without anyproblem
if you use sessions, that could be your problem, secure sessions use cookies so if you dont have cookies enabled your gonna be introuble
kevin7
Forum Commoner
Posts: 96
Joined: Fri May 21, 2004 6:54 am

Post by kevin7 »

Code: Select all

<?

session_start();
header("cache-control: private");

$id = (isset($_REQUEST&#1111;'id']) ? $_REQUEST&#1111;'id']: null);

if ($id==null) &#123;

	header('location:error_id.php?type=access_denied');

&#125; else &#123;


	require("sqlauth.php");
	$result = mysql_query("SELECT * FROM employee WHERE emp_id=$id",$db);

	if (!isset($_SESSION&#1111;'name'])) &#123;
		
		header('location:error_id.php?type=session_expired');
		&#125;
	
	$flag=0;
	
	while ($myrow = mysql_fetch_row($result)) &#123;

	if (($_SESSION&#1111;'name']==$myrow&#1111;0]) && ($_SESSION&#1111;'pass']==$myrow&#1111;12])) &#123;
		$flag=1;

		<!-- START OF CONTENT -->
		<!-- END OF CONTENT -->

		&#125;

	&#125;


	if ($flag==0) &#123;
		header('location:error_id.php?type=access_denied');
	&#125;

&#125;

?>

all my pages have this coding... i know it was a mess...

Code: Select all

$flag=0;
	
	while ($myrow = mysql_fetch_row($result)) &#123;

	if (($_SESSION&#1111;'name']==$myrow&#1111;0]) && ($_SESSION&#1111;'pass']==$myrow&#1111;12])) &#123;
		$flag=1;

		<!-- START OF CONTENT -->
		<!-- END OF CONTENT -->

		&#125;

	&#125;
in the line above... i use while loop to match the session id' name and pass with the database... if correct then display content... there hv a flag if the matches is meet... all the while... all the pages work for me, only one page hv faulty... it seem like the SESSION not match with the database... and the variable $flag=0... as a result... it jump to the following if statement...

Code: Select all

if ($flag==0) &#123;
		header('location:error_id.php?type=access_denied');
	&#125;
i realized, the problem was the session ID... but why it seem like erased... and after that, i cannot login anymore unless i close the browser and start it all again...
kevin7
Forum Commoner
Posts: 96
Joined: Fri May 21, 2004 6:54 am

Post by kevin7 »

ooo... i found the bug...

the session id for staff id change by itself... from 1000 to 1f00 ???

what is goin on??
Post Reply