- This topic is empty.
-
AuthorPosts
-
November 17, 2010 at 11:31 am #30715Historical Forums UserParticipant
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:
$message
// 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 = <<
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');
?>
November 17, 2010 at 6:22 pm #74799cybershotParticipantI 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.phpNovember 18, 2010 at 1:12 pm #74663Historical Forums UserParticipantHey 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?
November 18, 2010 at 1:19 pm #74652cybershotParticipantyea, 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 "";
}
?>
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.