form $_POST method acting strange
Posted: Sun Jul 30, 2006 6:16 am
Hello again,
So I am working with this script that allows an admin to enter a new user into the db. All forms used call the same page, addUser.php. However, I keep running into the same problem of the second form not working properly. Here is how I have my if statements set up.
When I run this script, the first form correctly shows up, and after I submit the info the confirmation screen correctly shows up, and after I confirm the error screen incorrectly shows up. The reason I don't understand this is, the only way the script is entering the first if statement is if isset($_POST["confirmUser"]) is true, but yet it skips over the elseif?
Any help would be greatly appreciated, thanks,
Jason
So I am working with this script that allows an admin to enter a new user into the db. All forms used call the same page, addUser.php. However, I keep running into the same problem of the second form not working properly. Here is how I have my if statements set up.
Code: Select all
if (isset($_POST["submitUser"]) OR isset($_POST["confirmUser"])) {
if (isset($_POST["submitUser"])) {
// Show the confirmation page
// Show the second form (confirmUser) which consists of a submit button and hidden variables
print "
<form name = 'confirmUser' action = 'addUser.php' method = 'POST'>
<input type = 'hidden' name = 'fname' value = '".$clean['fname']."' />
<input type = 'hidden' name = 'lname' value = '".$clean['lname']."' />
<input type = 'hidden' name = 'email' value = '".$clean['email']."' />
<input type = 'hidden' name = 'pword' value = '".$clean['password']."' />
<input type = 'submit' name = 'confirmUser' value = 'confirm' />
</form>";
}
elseif (isset($_Post["confirmUser"])) {
// Insert data into the database using the passed hidden values
}
else {
print "error";
}
}
else {
// Show the first form (submitUser) to allow the user to input values
print "
Add User Form
<br />
<br />
<form name = 'addUser' action = 'addUser.php' method = 'POST'>
First Name:
<input type = 'text' name = 'fname' maxlength = '30' />
<br />
Last Name:
<input type = 'text' name = 'lname' maxlength = '30' />
<br />
Email:
<input type = 'text' name = 'email' maxlength = '60' />
<br />
<h5>Note: The passwords will later be automatically generated and encrypted.<br />
The User will then be prompted (made) to change the password on the first login</h5>
Password:
<input type = 'password' name = 'pword' maxlength = '30' />
<br />
<br />
<input type = 'submit' name = 'submitUser' />
</form>";
}Any help would be greatly appreciated, thanks,
Jason