Overclock.net banner

1 - 4 of 4 Posts

·
Registered
Joined
·
3,483 Posts
Discussion Starter #1
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
 

·
Registered
Joined
·
531 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]
 

·
Registered
Joined
·
2,017 Posts
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.
 
1 - 4 of 4 Posts
Top