#18761 [NEW]: Simple Form Posting
| From: | theprizfam at charter dot net | Date: | Tue, 06 Aug 2002 18:10:42 +0000 |
| Subject: | #18761 [NEW]: Simple Form Posting | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-16087@lists.php.net to get a copy of this message | ||
From: theprizfam@charter.net
Operating system: Windows 2000
PHP version: 4.2.2
PHP Bug Type: HTTP related
Bug description: Simple Form Posting
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:
<?php
// 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;
session_start();
session_register('userID');
session_register('fullName');
session_register('userType');
session_register('userName');
session_register('password');
echo ("<p>Here I am!</p>");
header("Location: http://www.fancc.org/nbosp/menu.php");
exit;
}
else
{
$login = "no";
$err = "<p align=\"center\"><font color=red>The User or Password is
incorrect!</font></p>";
}
}
}
$form_block = "<form action=\"http://www.fancc.org/nbosp/login.php\"
method=\"POST\">
<p>
<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\">
</form>
";
?>
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>Spell</title>
</head>
<body background="Images/marble.jpg" bgcolor="#FFFFFF">
<p align="center"><font size="5"><strong>User
Login</strong></font></p>
<hr noshade color="#000000">
<?php
echo "$err";
echo "$form_block";
?>
</body>
</html>
--
Edit bug report at http://bugs.php.net/?id=18761&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=18761&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=18761&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=18761&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=18761&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=18761&r=support
Expected behavior: http://bugs.php.net/fix.php?id=18761&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=18761&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=18761&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=18761&r=globals