Overclock.net banner

PHP - Form submit not validating...

940 Views 3 Replies 3 Participants Last post by  koulaid
So I have a piece of code i wrote that doesn't seem to be working correctly.
It is a registration system and is just doing a bit of verification at the moment.
Here are the steps it should go through:
  • Show registration form
  • IF passwords and email address are the same - echo "Thanks"
  • IF passwords and email address's are NOT the same - Say "mismatch..."
However, the form is always showing the mismatch part and I cannot find a solution.
Here is the code

Code:
Code:
[CODE]
if (isset($_POST['submit'])) {

    if ($password == $password2 && $email == $email2) {
        echo "Thanks"; }
        else {
        echo "Password and/or Email Address Mismatch.  Please try again";
}
}
[/CODE]
+REP to helpers
1 - 4 of 4 Posts
try this

Code:
Code:
[CODE]
if (isset($_POST['submit'])) {

    if (($password == $password2) && ($email == $email2)) {
        echo "Thanks"; }
        else {
        echo "Password and/or Email Address Mismatch.  Please try again";
}
}
[/CODE]
Assuming $password, $password2, $email, and $email2 are variables from form fields, this:

Code:
Code:
[CODE]
if (($password == $password2) && ($email == $email2)) {
[/CODE]
Should be this:

Code:
Code:
[CODE]
if (($_POST['password'] == $_POST['password2']) && ($_POST['email'] == $_POST['email2'])) {
[/CODE]
This is a good habit, prevents some security problems, and should work no matter the php.ini settings.
See less See more
1 - 4 of 4 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top