...

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



raghu_life
01-12-2012, 12: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">
<head>
<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" />
</head>
<link rel="shortcut icon" href="http://www.biologysolutions.in/images/favicon.ico"/>
<body>
<h2>Contact form</h2>

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

<div id="contact_form">

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

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

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

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

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

</div>

</form>

</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>
<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>
</div>
</div> <!--end of main container-->
</body>
</html>

Here is my php Code:

<?php

/* 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
<br><hr><br>
Name: $name <br>
Email: $email <br>
Phone Number: $phone <br>
Message: $message <br>
EOD;

$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.

Raghunath.

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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum