php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16540 variables still exist after loading to a new page
Submitted: 2002-04-11 02:17 UTC Modified: 2002-07-07 13:33 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: webmaster at ckeren dot com Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.1.2 OS: win2K
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
48 + 9 = ?
Subscribe to this entry?

 
 [2002-04-11 02:17 UTC] webmaster at ckeren dot com
Below is the short script that produce quite stupid logics :)

//*************** start here



$header = "<html><head><title>BUGS</title></head><body><center><br><br><br><br>";

$min = 4;
$log = "<br><form action=\"$PHP_SELF\" method=post><table border=0 cellspacing=1 cellpadding=3>";
$log .= "<tr><td class=login colspan=2>Username<br><input type=text name=\"mumzu\" size=25 maxlength=20></td></tr>";
$log .= "<tr><td class=login colspan=2>Password<br><input type=password name=\"mumzp\" size=16 maxlength=20> <input align=\"texttop\" type=submit value=\"Log In\" class=\"submit\"></td></tr>";
$log .= "<tr><td valign=top><input type=\"radio\" name=\"mumzr\" value=\"1\"></td><td width=150><font class=option>Keep me loged-in into this MUMZ unless I logout.</font></td></tr>";
$log .= "<tr><td valign=top><input type=\"radio\" name=\"mumzr\" value=\"0\" checked></td><td width=150><font class=option>Do nothing.</font></td></tr></table></form><br><br>";


if((isset($HTTP_POST_VARS["mumzu"]) && isset($HTTP_POST_VARS["mumzp"]) && isset($HTTP_POST_VARS["mumzr"])) || (isset($HTTP_COOKIE_VARS["mumzu"]) && isset($HTTP_COOKIE_VARS["mumzp"]) && isset($HTTP_COOKIE_VARS["mumzr"])))
{
	if(!isset($p))
	{
		$m = 30;
		$lifetime = time() + ($m * 60);
		setcookie("mumzu", $mumzu, $lifetime);
		setcookie("mumzp", $mumzp, $lifetime);
		setcookie("mumzr", $mumzr, $lifetime);
		
		echo $header;
		echo "this is <b>Restricted area</b><br><br>click <a href=\"$PHP_SELF?p=logout\">here</a> to logout";
	}
	else if(isset($p) && $p == "logout")
	{
		setcookie("mumzu");
		setcookie("mumzp");
		setcookie("mumzr");
		echo $header;
		echo "<font color=\"#FF0000\">Here is the bug: the 3 variabels mumzu, mumzp, mumzr suppoused to be disapeared after clicking the link below.<br>And logically since there is no any existing variables it suppoused to display login form instead <b>restricted area</b> again</font><br><br>";
		echo "you have been loged out click <a href=\"$PHP_SELF\">here</a> to login again";
	}
	else
	{
		setcookie("mumzu");
		setcookie("mumzp");
		setcookie("mumzr");
		echo $header;
		echo "Bad username or password";
		echo $log;
	}

}
else
	echo $header.$log;

if(isset($mumzu))
	echo "<br><br>username: \"$mumzu\" , pass: \"$mumzp\", cookie mumzp: ".@$HTTP_COOKIE_VARS["mumzp"];


echo "</center></body></html>";

//***************End of Line

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-11 02:49 UTC] webmaster at ckeren dot com
The variables value stay empty after logout and will remain empty forever eventhough you try to login again with different value of username and password
 [2002-04-11 06:20 UTC] sander@php.net
The bug system is not the appropriate forum for asking support
questions. For a list of a range of more appropriate places to ask
for help using PHP, please visit http://www.php.net/support.php


 [2002-04-11 10:54 UTC] webmaster at ckeren dot com
This is not a support question (I KNOW WHAT I'M DOING AND I DO NOT NEED ANY HELP FROM SUPPORT) this is a bug that happened with your php version 4.1.2 under win2k platform

the script is just there to help you to understand where the bug is.

Just to tell you one more that this script is running perfectly under php version 4.0.6

I am just here to help you guys finding the bugs that's all!!!!!!!!!!!
 [2002-04-11 11:00 UTC] sander@php.net
OK, but can you strip your sample script down to only a couple of lines. Your script is waaaaaay to long, and then the bug is likely to be caused by programming errors.
Reopening.
 [2002-04-11 22:43 UTC] webmaster at ckeren dot com
ok here is the simpler script, please try it and you'll see very clearly where the bug is. It should work but logically it doesn't. That is because php doesn't flush the variables after loading a new page which normally it should. Instead it passess the variables with an empty string MAGICALY.


********************* Start of line


$header = "<html><head><title>BUGS</title></head><body><center><br><br><br><br>";
$log = "<br><form action=\"$PHP_SELF\" method=post>Username: <input type=text name=\"user\" size=25 maxlength=20><input type=submit></form>";
if((isset($HTTP_POST_VARS["user"]) || isset($HTTP_COOKIE_VARS["user"])))
{
	if(!isset($p))
	{
		$m = 30; //m variable represent minutes
		$lifetime = time() + ($m * 60); //lifetime variable represent the
		setcookie("user", $user, $lifetime); //set the user variable value into cookie
		
		echo $header; //Just to print html header
		
		//Print contents of restricted area
		echo "this is <b>Restricted area</b><br><br>click <a href=\"$PHP_SELF?p=logout\">here</a> to logout";
	}
	else if(isset($p) && $p == "logout")
	{
		setcookie("user"); //delete user cookie
		echo $header;
		echo "<font color=\"#FF0000\">Here is the bug: the variable user suppoused to be disapeared after clicking the link below.<br>And logically since there is no any existing variables it suppoused to display login form instead <b>restricted area</b></font><br><br>";
		echo "you have been loged out click <a href=\"$PHP_SELF\">here</a> to login again";
	}
	else
	{
		setcookie("user"); //delete user cookie
		echo $header;
		echo "Bad username or password";
		echo $log;
	}
}
else
	echo $header.$log;

if(isset($user))
	echo "<br><br>username: \"$user\" , cookie user: ".@$HTTP_COOKIE_VARS["user"];

echo "</center></body></html>";

********************* End of line
 [2002-05-12 00:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2002-05-12 03:19 UTC] mfischer@php.net
Feedback was given, just no one responded -> reopening.
 [2002-07-07 12:40 UTC] derick@php.net
Please try the latest non-stable snapshot from http://snaps.php.net and update this bugreport with the results of your problem with this new development version.

Derick
 [2002-07-07 13:33 UTC] sniper@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php

Thank you for your interest in PHP.


Please read this page:

http://www.php.net/manual/en/function.setcookie.php

And especially the paragraph about common pitfalls..

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 14 20:01:30 2024 UTC