PHP Email Form
Hello Peeps
Just started playing around in web design, i managed to acquire a template for my golf society friends, but i am unable to get the correct php form set up for the contact page. The code for the Form is below.
<form id="ContactForm" action="email.php" method="post">
<div>
<label><span class="input"><input type="text" value="Your Name:" onBlur="if(this.value=='') this.value='Your Name:'" onFocus="if(this.value =='Your Name:' ) this.value=''" /></span></label>
<label><span class="input"><input type="text" value="Your E-mail:" onBlur="if(this.value=='') this.value='Your E-mail:'" onFocus="if(this.value =='Your E-mail:' ) this.value=''" /></span></label>
<label><span class="input"><input type="text" value="Your State:" onBlur="if(this.value=='') this.value='Your State:'" onFocus="if(this.value =='Your State:' ) this.value=''" /></span></label>
<span class="textarea"><textarea onBlur="if(this.value=='') this.value='Your Message:'" onFocus="if(this.value =='Your Message:' ) this.value=''" >Your Message:</textarea></span>
</div>
<div class="alignright">
<a href="#" class="link" onClick="document.getElementById('ContactForm').reset()"><span><span>clear</span></span></a>
<a href="#" class="link" onClick="document.getElementById('ContactForm').submit()"><span><span>send</span></span></a>
</div>
</form>
I have searched the net for a solution and found the below, but i cannot get the message content to appear in the emails.
<?php
//--------------------------Set these paramaters--------------------------
// Subject of email sent to you.
$subject = 'Results from Contact form';
// Your email address. This is where the form information will be sent.
$emailadd = 'feedback@wsog.co.uk';
// Where to redirect after form is processed.
$url = 'http://www.wsog.co.uk/Contact.html';
// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '1';
// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>
any tips on how i can get the text to send would be very greatfull.
