Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Getting a "Enter Valid Email Address" error

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #25650
    Preeminent
    Participant

    Hi all,
    When I hit submit on my contact form I am getting an error telling me that the email address that was entered is not valid, even though I am testing it out with valid email addresses.
    I will go ahead and post up the pattern I am using to validate:

    Code:
    // If the email is set, validate and store it
    if(!empty($_POST[‘cf_e’]) && $_POST[‘cf_e’]!=’Email (required)’)
    {
    // Define a regex pattern to validate the email address
    $pattern = “/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/i”;
    if (preg_match($pattern, $_POST[‘cf_e’]))
    {
    $email = $_POST[‘cf_e’];
    }

    else
    {
    // If the email doesn’t match the pattern, error
    $err .= “Please enter a valid email address!
    “;
    }
    }

    I even looked up another pattern to use and it still didn’t work. Does anyone have any suggestions?

    #61858

    Are you working with PHP on your local machine, or on an external server and FTPing all your files up there? If you are using your computer with something like MAMP or XAMMP set up, most likely the server won’t be set up properly to send mail. I’d suggest uploading your files to your web host and testing it live there.

    #61871

    Have you been able to send emails using that host in the past? I know some hosts disable it for spam reasons.

    (In case you don’t know, you can check if it is disabled by looking at a file with this contents: <?php phpinfo(); ?>)

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.