I am sorry for what is a very basic question but I am very new to web design and I am just trying to get my form to work with php.
The form fills in fine, and I receive an email but I don't get any body text. Instead of telling me what the message is I get this:
You have received a new message from the user fgafdfa. Here is the message: info@sodium3.com
As you can see the name is there (just typed gibberish) however the message is missing, instead I get my own email address appearing...
Here is the HTML for the form:
<div id="form">
<form action="php/send_form_email.php" method="post" >
<span>Name</span>
<input type="text" name="name" class="name" />
<span>Email</span>
<input type="text" name="email" class="email"/>
<span>Message</span>
<textarea class="message"></textarea>
<input type="submit" name='submit' value="submit" class="submit">
</form>
</div>
Here's the php:
<?php
if(!isset($_POST['submit']))
{
//This page should not be accessed directly. Need to submit the form.
echo "error; you need to submit the form!";
}
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];
if(empty($name)||empty($visitor_email))
{
echo "Name and email are mandatory!";
exit;
}
if(IsInjected($visitor_email))
{
echo "Bad email value!";
exit;
}
$email_from = 'info@sodium3.com';//
$email_subject = "New Form submission";
$email_body = "You have received a new message from the user $name.
".
"Here is the message:
$message".
$to = "info@sodium3.com";//
$headers = "From: $email_from
";
$headers .= "Reply-To: $visitor_email
";
mail($to,$email_subject,$email_body,$headers);
header('Location: ../index.htm');
function IsInjected($str)
{
$injections = array('(
+)',
'(+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
);
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str))
{
return true;
}
else
{
return false;
}
}
?>
Can anyone help?