Forums

Give help. Get help.

  • # August 4, 2009 at 11:35 pm

    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?

    # August 7, 2009 at 8:59 pm

    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.

    # August 8, 2009 at 1:04 am

    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)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag