I am very new at php but even so, this does not make any sense to me:
I have an HTML page containing the php form as follows:
...
<article id="content"><div class="ic">Here comes the contact form!</div>
<div class="wrapper">
<h2>Contact form</h2>
<form method="post" id="ContactForm" name="myemailform" action="sendemail.php">
<div>
<div class="wrapper">
<span>Nume:</span>
<div class="bg"><input type="text" class="input" name="myname"></div>
</div>
<div class="wrapper">
<span>Adresa:</span>
<div class="bg"><input type="text" class="input" name="myadresa" ></div>
</div>
<div class="wrapper">
<span>Email:</span>
<div class="bg"><input type="text" class="input" name="myemail" ></div>
</div>
<div class="textarea_box">
<span>Mesaj:</span>
<div class="bg"><textarea name="textarea" cols="1" rows="1" name="mymesaj"></textarea></div>
</div>
<a href="#" class="button1" name='submit' value="submit" onclick='javascript: document.myemailform.binset=2; document.myemailform.submit();'>Send message</a>
</div>
</form>
</div>
</article>
And the action sendemail.php is as follows:
<?php
if(isset($_POST['submit'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "myreal_email#email.com";
$email_subject = "Message from contact form";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['myname']) ||
!isset($_POST['myadresa']) ||
!isset($_POST['myemail']) ||
!isset($_POST['mymesaj'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = $_POST['myname']; // required
$last_name = $_POST['myadresa']; // required
$email_from = $_POST['myemail']; // required
$comments = $_POST['mymesaj']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+#[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: ".clean_string($first_name)."\n";
$email_message .= "Adresa: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Mesaj efectiv: ".clean_string($comments)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
#mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
Thank you for contacting us. We will be in touch with you very soon.
<?php
}
?>
Now, the problem is that I receive the email, the subject is ok, the sender email is ok, but the message is empty... no $email_message is received.
Why is this happening?
Any help would be appreciated.
Thank you
the problem is with your
<textarea name="textarea" cols="1" rows="1" name="mymesaj"></textarea>
there are two names with the textarea check it.
<textarea cols="1" rows="1" name="mymesaj"></textarea>
if you are usinh HTML 5 or higher version...use 'required' in the input tags...which will automatically validate the input data is present or not...
like this:
<input type="text" class="input" name="myname" required>
and for email validation give the input type as email...not text
like this:
<input type="email" class="input" name="myemail" required >
Also try ajax,jquery for further form validations..
Related
This question already has answers here:
PHP code is not being executed, but the code shows in the browser source code
(35 answers)
Closed 5 years ago.
When I click my submit button, It pulls up my form-to-email.php source code. This is my first time using any PHP. How do i get it to send the email? It could just be linked incorrectly or formatted incorrectly.
<form method="post" name="myemailform" action="form-to-email.php">
<div>
<label for="name">Name:</label><br>
<input type="text" id="name" name="user_name" size="45"><br>
</div>
<div>
<label for="email">Email:</label><br>
<input type="text" id="email" name="user_email" size="45"><br>
</div>
<div>
<label for="message">Message:</label><br>
<textarea type="text" id="message" name="user_message" size="600"></textarea><br>
</div>
<div>
<input type = "submit" value = "Send Form">
<input type = "reset" value = "reset">
</div>
</form>
here is my PHP code
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "codymaheu#yahoo.com";
$email_subject = "Testing";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['user_name']) ||
!isset($_POST['user_email']) ||
!isset($_POST['user_message'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$name = $_POST['user_name']; // required
$email_from = $_POST['user_email']; // required
$comments = $_POST['user_message']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+#[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Message you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Message: ".clean_string($comments)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
#mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
Thank you for contacting us. We will be in touch with you very soon.
<?php
}
?>
add name into the button like this then try again
<input type = "submit" value = "Send Form" name="email">
I have a contact form that is coded in this way:
HTML CODE
<form enctype="text/plain" action="send_form_email.php" method="post" role="form">
<div class="col-md-1 col-sm-1"></div>
<div class="col-md-10 col-sm-10">
<div class="col-md-6 col-sm-6">
<input name="Emri" type="text" class="form-control" id="name" placeholder="Emri">
</div>
<div class="col-md-6 col-sm-6">
<input name="Email" type="email" class="form-control" id="email" placeholder="Email">
</div>
<div class="col-md-12 col-sm-12">
<input name="Sbjekti" type="text" class="form-control" id="subject" placeholder="Subjekti">
</div>
<div class="col-md-12 col-sm-12">
<textarea name="Msazhi" rows="5" class="form-control" id="message" placeholder="Mesazhi"></textarea>
</div>
<div class="col-md-6 col-sm-6">
<input name="Dergo" type="submit" class="form-control" id="submit" value="DERGO">
</div>
</div>
<div class="col-md-1 col-sm-1"></div>
</form>
I have connected it with a php code called send_form_email.php
PHP CODE
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "xhesjanatopalli#gmail.com";
$email_subject = "Your email subject line";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = $_POST['first_name']; // required
$last_name = $_POST['last_name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+#[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
#mail($email_to, $email_subject, $email_message, $headers);
?>
<?php
}
?>
I have added my email address, but this is not working, when i click submit, send_form_email.php is being downloaded.
Can anyone please help me?
Thanks a lot
PHP is a server-side scripting language, are you running your code in a server that support PHP?
If not, you can easily setup your PHP enviroment with a software like XAMPP
I want to validate a drop down select on a form, I want the visitor to select one value, any value is ok. I can put values manually, so no need for anything complicated like arrays.
I can understand the validation for email and name, but how can I do this for a drop down select?
I put the form online over here:
http://satearn.com/question/landing_page.html
<form name="contactform" method="post" action="send_form_email.php">
<div class="section">
<span>1</span>First & Last Name</div>
<div class="inner-wrap testbruno">
<input type="text" name="first_last_name" class="form-style-10-input">
</div>
<div class="section">
<span>2</span>Email Address</div>
<div class="inner-wrap">
<input type="email" name="email" class="form-style-10-input">
</div>
<div class="section">
<span>3</span>Budget</div>
<div class="inner-wrap">
<select name="budget_selection" class="form-style-10-drop-down">
<option value="$499">$499</option>
<option value="$999">$999</option>
</select>
</div>
<div>
<input name="Sign Up" type="submit" value="Send">
</div>
</form>
Under is the PHP page:
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "bruno#xuzo.com";
$email_subject = "My own subject Line Bruno";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['first_last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['budget_selection'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_last_name = $_POST['first_last_name']; // required
$email_from = $_POST['email']; // required
$budget_selection = $_POST['budget_selection']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+#[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_last_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Customer First Name: ".clean_string($first_last_name)."\n";
$email_message .= "Customer Email: ".clean_string($email_from)."\n";
$email_message .= "Budget Selection: ".clean_string($budget_selection)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
#mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
Thank you for contacting us. We will be in touch with you very soon.
<?php
}
?>
add like this
<select name="budget_selection" class="form-style-10-drop-down" required='required' >
<option value="">select</option>
<option value="$499">$499</option>
<option value="$999">$999</option>
</select>
It just client side browser validation you have to validate in server side also.
i have form which i use on my page for client to be able to send me some messages. Everythings is ok and working. The one thing which is missing is that every form errors and result like (email typ error, first name missing) are showing up on new page. What i would like to have is on same page to have notifications and also result e.g "Your message has been send". I saw in some pages forms input can be highlitet on red if something is putted wrong etc. I read that this can be done either by ajax or jquery but to be honest i am not so familaiar with it. In my solution i am using bootstrap and php. Can you help me to achieve that? Below my current code.
html (using bootstrap):
<form action="send_form_email.php" method="post" class="form-horizontal">
<div class="form-group">
<label for="first_name" class="col-lg-2 control-label">First name</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="first_name" name="first_name" placeholder="Enter you first name">
</div>
</div><!-- End form group -->
<div class="form-group">
<label for="last_name" class="col-lg-2 control-label">Last name</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="last_name" name="last_name" placeholder="Enter you last name">
</div>
</div><!-- End form group -->
<div class="form-group">
<label for="email" class="col-lg-2 control-label">Email</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="email" name="email" placeholder="Enter you Email Address">
</div>
</div><!-- End form group -->
<div class="form-group">
<label for="telephone" class="col-lg-2 control-label">Telephone</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="telephone" name="telephone" placeholder="Enter you phone number">
</div>
</div>
<div class="form-group">
<label for="comments" class="col-lg-2 control-label">Any Message</label>
<div class="col-lg-10">
<textarea name="comments" id="comments" name="comments" class="form-control"
cols="20" rows="10" placeholder="Enter your Message"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</form>
here's php that handle email sending and form validation:
<?php
if(isset($_POST['email']))
{
// CHANGE THE TWO LINES BELOW
$email_to = "myemail#gmail.com";
$email_subject = "Nowy formularz od osoby";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errorsbr /><br />";
echo '<input type="button" value="BACK" onclick="history.back();">';
die();
}
// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = $_POST['first_name']; // required
$last_name = $_POST['last_name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+#[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Zawartosc wypelnionego formularza\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($email_to, $email_subject, $email_message)) {
echo "Dziekuje za kontakt postaram sie odezwac jak najszybciej | Thank you for contacting me. I will be in touch with you very soon.";
echo '<input type="button" value="BACK" onclick="history.back();">';
}else{
echo "Nie wyslano z z powodu nieznanego bledu prosze sprobuj ponownie lub zadzwon do mnie bezposrednio | Form was not send due to unknown reason please go back and try again if it would not help please try to rich me directly on my phone.<br/><br/><br/><br/>";
echo '<input type="button" value="BACK" onclick="history.back();">';
}
}
// die();
Change From
<form action="send_form_email.php" method="post" class="form-horizontal">
To
<form action="" method="post" class="form-horizontal">
Then save your HTML file as PHP and add your PHP code in top of form page
Updated PHP code for custom style error messages.
<?php
if(isset($_POST['email']))
{
// CHANGE THE TWO LINES BELOW
$email_to = "myemail#gmail.com";
$email_subject = "Nowy formularz od osoby";
function died($error)
{
// your error code can go here
// Adding bootstrap style class
echo '<div class="alert alert-warning" role="alert">';
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
//Not needed any more
//echo "Please go back and fix these errorsbr /><br />";
//echo '<input type="button" value="BACK" onclick="history.back();">';
echo '</div>';
die();
}
// New function style the error messages
function styleErrorMsg($string)
{
$string = '<div class="alert alert-warning" role="alert">'.$string.'</div>';
return $string;
}
// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['comments']))
{
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = $_POST['first_name']; // required
$last_name = $_POST['last_name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+#[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from))
{
$error_message .= styleErrorMsg('The Email Address you entered does not appear to be valid.<br />');
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name))
{
$error_message .= styleErrorMsg('The First Name you entered does not appear to be valid.<br />');
}
if(!preg_match($string_exp,$last_name))
{
$error_message .= styleErrorMsg('The Last Name you entered does not appear to be valid.<br />');
}
if(strlen($comments) < 2)
{
$error_message .= styleErrorMsg('The Comments you entered do not appear to be valid.<br />');
}
if(strlen($error_message) > 0)
{
died($error_message);
}
$email_message = "Zawartosc wypelnionego formularza\n\n";
function clean_string($string)
{
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($email_to, $email_subject, $email_message))
{
echo "Dziekuje za kontakt postaram sie odezwac jak najszybciej | Thank you for contacting me. I will be in touch with you very soon.";
echo '<input type="button" value="BACK" onclick="history.back();">';
}
else
{
echo "Nie wyslano z z powodu nieznanego bledu prosze sprobuj ponownie lub zadzwon do mnie bezposrednio | Form was not send due to unknown reason please go back and try again if it would not help please try to rich me directly on my phone.<br/><br/><br/><br/>";
echo '<input type="button" value="BACK" onclick="history.back();">';
}
}
// die();
?>
My form doesn't generate an E-Mail it just redirects me to a blank page.
i have my .php form in a folder named php on my server
thank you for your help.
here is my html code
<form id="form" method="post" action="php/send_form_email.php">
<fieldset>
<label><strong>Name:</strong>
<input type="text" value="">
</label>
<label><strong>Email:</strong>
<input type="text" value="">
</label>
<label><strong>Phone:</strong>
<input type="text" value="">
</label>
<label><strong>Message:</strong>
<textarea></textarea>
</label>
<div class="btns">ClearSend</div>
</fieldset>
</form>
here is the php code i'm using:
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "###.com";
$email_subject = "havok security contact form";
function died($error) {
// your error code can go here
echo "We are very sorry, but there was an error found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['phone']) ||
!isset($_POST['message'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$telephone = $_POST['phone']; // not required
$comments = $_POST['message']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+#[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name)) {
$error_message .= 'The Name you entered does not appear to be valid.<br />';
}
if(strlen($message) < 2) {
$error_message .= 'The Message you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: ".clean_string($first_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Phone: ".clean_string($telephone)."\n";
$email_message .= "Message: ".clean_string($comments)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
#mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
Thank you for contacting us. We will be in touch with you very soon.
<?php
}
?>
The input type under email needs to have a name attribute called "email". Your PHP script is looking to see if $_POST["email"] is set, and it is not. So, this should work:
<form id="form" method="post" action="php/send_form_email.php">
<fieldset>
<label><strong>Name:</strong>
<input type="text" name="name" value="">
</label>
<label><strong>Email:</strong>
<input type="text" name="email" value="">
</label>
<label><strong>Phone:</strong>
<input type="text" name="phone" value="">
</label>
<label><strong>Message:</strong>
<textarea name = "message"></textarea>
</label>
<div class="btns">ClearSend</div>
</fieldset>
</form>