lcot
10-03-2010, 01:46 PM
Hello, I am having a problem with my contact form php script.
When I use the form and submit it, it sends an email to the right place and the body and subject of the mail is correct but the values that I typed in such as name and email do not show up. In the email it is simply:
The website where I am implementing this mailer to test it is here:
http://www.livingfortodayband.co.uk/basement2/contact.html
(http://www.livingfortodayband.co.uk/basement2/contact.html)
______________________________________…
Name:
Email:
Artist:
Subject:
Message:
It is empty. My current PHP code is as follows:
<?php
/* Subject and Email Variables */
$emailSubject = 'Basement Studio Web Enquiry';
$webMaster = 'info@basement-studios.co.uk';
/* Gathering Data Variables */
$nameField = $_POST['name'];
$emailField = $_POST['email'];
$artistField = $_POST['artist'];
$subjectField = $_POST['subject'];
$messageField = $_POST['message'];
$body = <<<EOD
<br><hr><br>
Name: $name<br>
Email: $email<br>
Artist: $artist<br>
Subject: $subject<br>
Message: $message<br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$seccess = mail($webMaster, $emailSubject, $body, $headers);
/* Results as HTML */
$theResults = <<<EOD
<html><body>Congrats!!</body></html>
EOD;
echo "$theResults";
?>
The HTML of the form I am using is here :
<form action="mailer.php" method="post" enctype="multipart/form-data" id="contactform">
<ol>
<li>
<label for="name">First Name <span class="required">*</span></label>
<input id="name" name="name" class="text">
</li>
<li>
<label for="email">Your email <span class="required">*</span></label>
<input id="email" name="email" class="text" />
</li>
<li>
<label for="artist">Band/Artist Name</label>
<input id="artist" name="artist" class="text">
</li>
<li>
<label for="subject">Subject</label>
<input id="subject" name="subject" class="text">
</li>
<li>
<label for="message">Message <span class="required">*</span></label>
<textarea id="message" name="message" rows="6" cols="50"></textarea>
</li>
<li>
<label for="valid">Seven + Four =</label>
<input name="valid" type="text" class="text" id="valid" onblur="MM_validateForm('element_5','','NinRange11:11');return document.MM_returnValue" size="5" maxlength="2" if="element_5" />
</li>
<li class="buttons">
<input name="imageField" id="imageField" src="images/send.jpg" class="send" type="image">
<div class="clr"></div>
</li>
</ol>
</form>
I will be so grateful if someone can help me in finding out what is wrong with my script.. also if anyone has any idea how to involve an IP address of the person who submitted the form into the body of the email that would be fantastic
Thanks in advance
When I use the form and submit it, it sends an email to the right place and the body and subject of the mail is correct but the values that I typed in such as name and email do not show up. In the email it is simply:
The website where I am implementing this mailer to test it is here:
http://www.livingfortodayband.co.uk/basement2/contact.html
(http://www.livingfortodayband.co.uk/basement2/contact.html)
______________________________________…
Name:
Email:
Artist:
Subject:
Message:
It is empty. My current PHP code is as follows:
<?php
/* Subject and Email Variables */
$emailSubject = 'Basement Studio Web Enquiry';
$webMaster = 'info@basement-studios.co.uk';
/* Gathering Data Variables */
$nameField = $_POST['name'];
$emailField = $_POST['email'];
$artistField = $_POST['artist'];
$subjectField = $_POST['subject'];
$messageField = $_POST['message'];
$body = <<<EOD
<br><hr><br>
Name: $name<br>
Email: $email<br>
Artist: $artist<br>
Subject: $subject<br>
Message: $message<br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$seccess = mail($webMaster, $emailSubject, $body, $headers);
/* Results as HTML */
$theResults = <<<EOD
<html><body>Congrats!!</body></html>
EOD;
echo "$theResults";
?>
The HTML of the form I am using is here :
<form action="mailer.php" method="post" enctype="multipart/form-data" id="contactform">
<ol>
<li>
<label for="name">First Name <span class="required">*</span></label>
<input id="name" name="name" class="text">
</li>
<li>
<label for="email">Your email <span class="required">*</span></label>
<input id="email" name="email" class="text" />
</li>
<li>
<label for="artist">Band/Artist Name</label>
<input id="artist" name="artist" class="text">
</li>
<li>
<label for="subject">Subject</label>
<input id="subject" name="subject" class="text">
</li>
<li>
<label for="message">Message <span class="required">*</span></label>
<textarea id="message" name="message" rows="6" cols="50"></textarea>
</li>
<li>
<label for="valid">Seven + Four =</label>
<input name="valid" type="text" class="text" id="valid" onblur="MM_validateForm('element_5','','NinRange11:11');return document.MM_returnValue" size="5" maxlength="2" if="element_5" />
</li>
<li class="buttons">
<input name="imageField" id="imageField" src="images/send.jpg" class="send" type="image">
<div class="clr"></div>
</li>
</ol>
</form>
I will be so grateful if someone can help me in finding out what is wrong with my script.. also if anyone has any idea how to involve an IP address of the person who submitted the form into the body of the email that would be fantastic
Thanks in advance