Forums

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

Home Forums Back End Send Email form help

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #30715

    Hey All,

    I’m using the Send Email snippet on the latest site I’m developing. My problem is the form doesn’t send if you fill out the email input correctly i.e [email protected] but if you just put your name i.e JohnSmith or email without an @ symbol it sends just fine.

    This is quite frustrating and if anyone have any ideas on how to fix this I would really appreciate it.

    Thanks!

    Here’s the code from the snippet.

    HTML:















    PHP:


    // from the form
    $name = trim(strip_tags($_POST));
    $email = trim(strip_tags($_POST));
    $message = htmlentities($_POST);

    // set here
    $subject = "Contact form submitted!";
    $to = '[email protected]';

    $body = << $message
    HTML;

    $headers = "From: $emailrn";
    $headers .= "Content-type: text/htmlrn";

    // send the email
    mail($to, $subject, $body, $headers);

    // redirect afterwords, if needed
    header('Location: thanks.html');
    ?>

    #74799
    cybershot
    Participant

    I believe the strip_tags function is striping the email address. It is taking out the @ sign. You need to tell the function to allow that sign. like this


    $email = trim(strip_tags($_POST, '@'));

    read up on the function
    http://php.net/manual/en/function.strip-tags.php

    #74663

    Hey cybershot thanks for helping out. I try it with the code change but it’s still not letting the email with @ go through. Did you have any other suggestions?

    #74652
    cybershot
    Participant

    yea, get rid of the srtip_tags all together. Just try


    $email = $_POST;

    try it and see what happens

    if that doesn’t work, I know this one does. just modify it to fit your needs

    // Website Contact Form Generator
    // http://www.tele-pro.co.uk/scripts/contact_form/
    // This script is free to use as long as you
    // retain the credit link

    // get posted data into local variables
    $EmailFrom = "your site";
    $EmailTo = "Your Email Here";
    $Subject = "contact form information";
    $name = Trim(stripslashes($_POST));
    $surname = Trim(stripslashes($_POST));
    $email = Trim(stripslashes($_POST));
    $city = Trim(stripslashes($_POST));
    $comments= Trim(stripslashes($_POST));

    // validation
    $validationOK=true;
    if (Trim($contactName) || Trim($surname) || Trim($contactEmail) || Trim($ContactCity) == " ")
    {
    $validationOK = false;
    }

    if (!$validationOK)
    {
    print "";
    exit;
    }

    // prepare email body text
    $Body = "";
    $Body .= "Name: ";
    $Body .= $name;
    $Body .= "n";
    $Body .= "Surname:";
    $Body .= $surname;
    $Body .= "n";
    $Body .= "Email: ";
    $Body .= $email;
    $Body .= "n";
    $Body .= "City: ";
    $Body .= $city;
    $Body .= "n";
    $Body .= "Comments: ";
    $Body .= $comments;
    $Body .= "n";

    // send email
    $success = mail($EmailTo, $Subject, $Body . "From: " . $EmailFrom);

    // redirect to success page
    if ($success){
    print "";
    }
    else{
    print "";
    }
    ?>

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