View Full Version : Struggling to get the content from the html form through php script

01-12-2012, 01:49 PM
My html form is send me empty emails. Kindly help me with this. I'll be grateful to you all.

My HTML Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Biology Solutions</title>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<link rel="shortcut icon" href="http://www.biologysolutions.in/images/favicon.ico"/>
<h2>Contact form</h2>

<form name="contactform" method="post" action="send_form_email.php">

<div id="contact_form">

<div class="form_row">
<input type="text" name="name" class="contact_input" />

<div class="form_row">
<input type="text" name="email" class="contact_input" />

<div class="form_row">
<input type="text" name="phone" class="contact_input" />

<div class="form_row">
<textarea name="message" class="contact_textarea"></textarea>

<div class="send">
<a href="http://www.biologysolutions.in/send_form_email.php">send</a>



</div><!--end of right content-->

<div style=" clear:both;"></div>
</div><!--end of main content-->

<div id="footer">
<div class="copyright">
<a href="home.html"><img src="images/footer_logo.gif" border="0" alt="" title="" /></a>
<div class="footer_links">
<a href="about.html">About us</a>
<a href="privacy.html">Privacy policy</a>
<a href="contact.html">Contact us </a>

</div> <!--end of main container-->

Here is my php Code:


/* Subject and Email Variables */

$emailsubject = 'New Message';
$webMaster = 'info@website.in'; /* Here I've given my email*/

/* Gathering Data Variables */

$nameField = $_POST['name'];
$emailField = $_POST['email'];
$phoneField = $_POST['phone'];
$messageField = $_POST['message'];

$body = <<<EOD
Name: $name <br>
Email: $email <br>
Phone Number: $phone <br>
Message: $message <br>

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailsubject, $body, $headers);

Once again I'm requesting you all to help me. I've been struggling to get this right for the past three days and I'm frustrated. Desperate to get this done. Help me.


01-12-2012, 02:20 PM
This line:
$success = mail($webMaster, $emailsubject, $body, $headers);

What is the value of $success? - true or false?