Create Contact Form And Send Email using PHP

Create Contact Form And Send Email using PHP

In this Post We Will Explain About is Create Contact Form And Send Email using PHP With Example and Demo.Welcome on Live24u.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to How to send email from contact form using PHPExample

In this post we will show you Best way to implement How to Simple PHP Mail Function Contact Us Page PHP Mail Script, hear for Email Form – Simple Form to Email PHP Contact Formwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Also Read :   php - SMTP Send mail using PHPMailer PHP Contact Form




You will first of all make a simple contact form with 3 fields using PHP Like as a – Email address, Users Name, and messages. We will use a simple table to align the 3 simple fields and the Send simple button.make Contact Form And Send Email In PHP

<form action="live_contact.php" method="post"> 
<table width="400" border="0" cellspacing="2" cellpadding="0"> 
<tr> 
<td class="form-data">First name:</td> 
<td><input name="name" type="text" id="name"></td> 
</tr> 
<tr> 
<td class="form-data">Email address:</td> 
<td><input name="email" type="text" id="email"></td> 
</tr> 
<tr> 
<td class="form-data">message:</td> 
<td><textarea name="message" cols="45" rows="6" id="message" class="form-data"></textarea></td> 
</tr> 
<tr> 
<td class="form-data"> </td> 
<td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td> 
</tr> 
</table> 
</form>

make a new file and just paste the source code below in it.and then Save it as live_contact.php and upload it to your linux or xampp or wampp web server. and then, We have a simple PHP web page (http://www.live24u.com/live_contact.php) with a simple data contact form on it.

Also Read :   Basic PHP String Functions - string to date,Text file to array and wordwrap





<?php 
    $email_to = 'live24u@live24u.com'; 
    $subject_email = 'Live contact us Site contact form inquiry'; 
    $header_mail = "From: ".$_POST["email"]."\r\n"; 
    $header_mail .= "Reply-To: ".$_POST["email"]."\r\n"; 
    $header_mail .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
    $email_body = "Good Name: ".$_POST["name"].""; 
    $email_body .= "Good Email: ".$_POST["email"].""; 
    $email_body .= "Good message: ".nl2br($_POST["message"]).""; 
    mail($email_to, $subject_email, $email_body, $header_mail) or die ("Failure"); 
?> 
Your simple email message was sent successfully!!
?>

<?php 
if ($_POST["email"]<>'') { 
    $email_to = 'live24u@live24u.com'; 
    $subject_email = 'Live contact us Site contact form inquiry'; 
    $header_mail = "From: ".$_POST["email"]."\r\n"; 
    $header_mail .= "Reply-To: ".$_POST["email"]."\r\n"; 
    $header_mail .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
    $email_body = "Good Name: ".$_POST["name"].""; 
    $email_body .= "Good Email: ".$_POST["email"].""; 
    $email_body .= "Good message: ".nl2br($_POST["message"]).""; 
    mail($email_to, $subject_email, $email_body, $header_mail) or die ("Failure"); 
?> 
Your simple email message was sent successfully!!
<?php 
} else { 
?> 
<form action="live_contact.php" method="post">
<table width="400" border="0" cellspacing="2" cellpadding="0">
<tr>
<td class="form-data">First name:</td>
<td><input name="name" type="text" id="name" size="32"></td>
</tr>
<tr>
<td class="form-data">Email address:</td>
<td><input name="email" type="text" id="email" size="32"></td>
</tr>
<tr>
<td class="form-data">message:</td>
<td><textarea name="message" cols="45" rows="6" id="message" class="form-data"></textarea></td>
</tr>
<tr>
<td class="form-data"> </td>
<td align="left"><input type="submit" name="Submit" value="Send"></td>
</tr>
</table>
</form> 
<?php 
}; 
?>





Example

Also Read :   Stripe API Master - Download Stripe API using PHP

I hope you have Got What is Creating a Simple Contact Form with PHP And how it works.I would Like to have FeadBack From My Blog(live24u.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(live24u.com) Are Most Always Welcome.