A person goes to register.php and fills out the form. The form action is
Code: Select all
$_SERVER['PHP_SELF']Here is the code. I'll tell you what the problem is after you've looked at the code (you'll probably be able to see it in the code anyways).
*Edited after feyd's reply.
Code: Select all
<HTML>
<HEAD>
<TITLE>Sign Up</TITLE>
</HEAD>
<BODY>
<?php $Self = $_SERVER['PHP_SELF'];
IF ($_POST['Action'] == "Submitted")
{
IF ($_POST['Password1'] != $_POST['Password2'])
{
ECHO "Your passwords did not match. Please try again";
INCLUDE 'FORMRETRY.php';
}
ELSEIF ((STRLEN($_POST['Location'])) != 2)
{
ECHO "Please give the two-letter abbreviation of the state in which you live.";
INCLUDE 'FORMRETRY.php';
}
ELSE
{
$Login=ADDSLASHES(HTMLSPECIALCHARS($_POST['Login']));
$Password=md5($_POST['Password1']);
$Email=ADDSLASHES(HTMLSPECIALCHARS($_POST['Email']));
$Name=HTMLSPECIALCHARS($_POST['Name']);
$Location=$_POST['Location'];
INCLUDE ("db_connect.php");
$sql = "INSERT into Members (Login, Password, Email, Name, Location)
VALUES('$Login','$Password','$Email','$Name','$Location')";
mysql_query($sql) or die(mysql_error());
ECHO "Congratulations, you are now a member.";
}
}
ELSE
{
INCLUDE 'FORM.php';
}
?>
</BODY>
</HTML>*Edited after feyd's reply.
Code: Select all
<form action="<?php ECHO $Self; ?>" method="POST">
<div>Desired Username:</div><INPUT TYPE="text" name="Login" SIZE="20"><br>
<div>Desired Password:</div><INPUT TYPE="password" name="Password1" SIZE="20"><br>
<div>Verify Password:</div><INPUT TYPE="password" name="Password2" SIZE="20"><br>
<div>Email Address:</div><INPUT TYPE="text" name="Email" SIZE="20"><br>
<div>First Name:</div><INPUT TYPE="text" name="First_Name" SIZE="20"><br>
<div>State:</div><INPUT TYPE="text" name="Location" SIZE="2"><br>
<input type="hidden" name="Action" value="Submitted">
<INPUT TYPE="submit" action="submit" name="submit" value="Register">*Edited after feyd's reply.
Code: Select all
<form action="<?php ECHO $Self; ?>" method="post">
<div>Desired Username:</div>
<INPUT TYPE="text" name="Login" SIZE="20" VALUE="<?php ECHO $_POST['Login']; ?>"><br>
<div>Desired Password:</div><INPUT TYPE="password" name="Password1" SIZE="20"><br>
<div>Verify Password:</div><INPUT TYPE="password" name="Password2" SIZE="20"><br>
<div>Email Address:</div><INPUT TYPE="text" name="Email" SIZE="20" VALUE="<?php ECHO $_POST['Email']; ?>"><br>
<div>First Name:</div><INPUT TYPE="text" name="First_Name" SIZE="20" VALUE="<?php ECHO $_POST['First_Name']; ?>"><br>
<div>State:</div><INPUT TYPE="text" name="Location" SIZE="2" VALUE="<?php ECHO $_POST['Location']; ?>"><br>
<input type="hidden" name="Action" value="Submitted">
<INPUT TYPE="submit" action="submit" name="submit" value="Register">http://mlowery.t35.com/CMS/register.php
According to my logic, initially:
Code: Select all
$_POST['Action'] != 'Submitted'1. Why are both forms being displayed?
2. Why is the password verification not working? When I type two different passwords, I am supposed to get an error message.
3. Why, in the form $FORMRETRY are not all the fields being displayed? (I have a feeling it is with the quotes).43. Line 16 --> "ELSEIF ((STRLEN($_POST['Location'])) != 2)" does not seem to be working properly. Even whenever I only type 2 characters for the state, it does not count 2 for some reason and prints the proceding error message.
Thanks,
Mitch