Create error if two fields don't match

Discussion in 'PHP' started by chrisj, Jul 20, 2007.

  1. #1
    I have a script with an account_create_page, which requires user name, password, name, address, email address etc.

    I wanted the user name to be the email address, so for simplicity I changed the field text for "User Name" to "Email Address" and changed the field text for "Email Address" to "Re-Confirm Email Address".

    Is there a way to add code that will get an error if these two fields don't match each other?

    thanks
     
    chrisj, Jul 20, 2007 IP
  2. Greg Carnegie

    Greg Carnegie Peon

    Messages:
    385
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If you want to do this in PHP then siply all you need to do is:
    
    if($_POST['email']!=$_POST['confirm-email'])
    {
        // error
    }
    
    PHP:
    I assume here you are sending data via POST and your input fields have names: email and confirm-email.
     
    Greg Carnegie, Jul 20, 2007 IP