|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18761 Simple Form Posting
Submitted: 2002-08-06 14:10 UTC Modified: 2002-08-07 14:58 UTC
From: theprizfam at charter dot net Assigned:
Status: Not a bug Package: HTTP related
PHP Version: 4.2.2 OS: Windows 2000
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: theprizfam at charter dot net
New email:
PHP Version: OS:


 [2002-08-06 14:10 UTC] theprizfam at charter dot net
Posting data from a form does not work. I have included a sample login form below that used to work on older versions of PHP. I add two echo statements (which you can see in the code below) for debugging purposes. I uncoment any of the ones that print the posting data and the script works. If I uncomment the ones that print the posted data it never reaches the "Here I am!" echo just before the redirect. It works fine if the user or password are not in the database but if the password and user are correct this is when it fails (i.e. it never gets to the echo statement "Here I am!"). 

Here is the script:

	// echo ("<p>User Name = $userName, Password = $password, op = $op</p>");
	$fontColor[0] = "color=black";
	$fontColor[1] = "color=black";

$login = "no";

if ($op == "ds")
	$login = "yes";

	// check each required field and create an error message.
	// if any of the required fields are blank, set $login to "no".

	if ($userName == "")
		$err = "<p align=\"center\"><font color=red>There are errors!</font></p>";
		$login = "no";
		$fontColor[0] = "color=red";

	if ($password == "") {

		$err = "<p align=\"center\"><font color=red>There are errors!</font></p>";
		$login = "no";
		$fontColor[1] = "color=red";

    if ($login == "yes")

		// echo ("<p>User Name = $userName, Password = $password, op = $op</p>");
		mysql_connect('localhost', 'userlogin', 'password') or die (mysql_error());
		mysql_select_db('database') or die (mysql_error());

		$result = mysql_query ("SELECT * FROM `users` WHERE User='$userName' AND Password=PASSWORD('$password')")
				or die (mysql_error());
		// echo ("<p>User Name = $userName, Password = $password, op = $op</p>");
		if ($row = mysql_fetch_object ($result))
			$userID = $row->UserID;
			$fullName = $row->FullName;
			$userType = $row->Type;
			$email = $row->Email;


			echo ("<p>Here I am!</p>");

			$login = "no";
			$err = "<p align=\"center\"><font color=red>The User or Password is incorrect!</font></p>";


$form_block = "<form action=\"\" method=\"POST\">
    <font size=\"2\" $fontColor[0]><strong>User</strong></font><br>
    <input type=\"text\" size=\"20\" name=\"userName\" value=\"$userName\"><br>
    <font size=\"2\" $fontColor[1]><strong>Password</strong></font><br>
    <input type=\"password\" size=\"20\" name=\"password\" value=\"$password\"></p>
    <p><input type=\"submit\" name=\"B1\" value=\"Login\"></p>
    <p>*If you have forgotten your password press here.</p>
    <input type=\"hidden\" name=\"op\" value=\"ds\">



<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">

<body background="Images/marble.jpg" bgcolor="#FFFFFF">

<p align="center"><font size="5"><strong>User Login</strong></font></p>

<hr noshade color="#000000">

		echo "$err";
		echo "$form_block";



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-06 14:12 UTC] theprizfam at charter dot net
Sorry, I ment when I comment out the echos that show the data posted it never reaches the "Here I am!" echo statement.
 [2002-08-06 14:18 UTC]
In PHP 4.2.0, the 'register_globals' setting default changed to
be off. See for more info.
We are sorry about the inconvenience, but this change was a necessary
part of our efforts to make PHP scripting more secure and portable.
 [2002-08-06 14:19 UTC]
Just kidding.  Itchy trigger finger.
 [2002-08-06 14:52 UTC] theprizfam at charter dot net
I checked the varialbles using phpinfo and it states that 'register_globals' is on.
 [2002-08-07 03:23 UTC]
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.

 [2002-08-07 14:58 UTC]
Probably dupe of #18765
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Mar 20 13:03:39 2023 UTC