I have a bit of programming knowledge, but not much, I was trying to create a PHP form, that when you clicked send, it sent the details that the person had entered in the form to my email address. Can anyone help as to why it is not working? p.s. I have used test email addresses in this code only, i use really addresses when testing.
form code im using:
<form action="contact.php" method="post">
<p style="text-align: center"><span style="font-size: 5pt"><br>
</span><b><font size="3">How Many Years have we been in Business?</font><font size="2"> </font></b>
<br>
<span style="font-size: 5pt">
<br>
</span>
<font size="2"><b>Answer:</b>
</font><font size="1">
<input type="text" name="cf_answer" size="6"></font><font size="2">
years<br>
</font><font style="font-size: 5pt">
<br>
</font><font size="2">
Your name:
</font><font size="1">
<input type="text" name="cf_name" size="24"></font><font size="2">
Company Name:
</font>
<input type="text" name="cf_company" size="23"><br>
<font style="font-size: 5pt">
<br>
</font>
<font size="2">
Email:
</font>
<input type="text" name="cf_email" size="63"><font size="2">
<br>
<br>
</font><b>
<font size="3">
Which Products/Services could we<br>
assist you with?</font><font size="2"><br>
</font>
</b><font style="font-size: 5pt"><br>
</font>
<font size="3">
<input type="checkbox" name="check[]" value="VehicleGraphics" style="font-weight: 700"></font><b><font size="2">
Vehicle Graphics </font></b><font size="3">
<input type="checkbox" name="check[]" value="GraphicDesign" style="font-weight: 700"><b><font size="2">
Graphic Design </font></b>
<input type="checkbox" name="check[]" value="Signage" style="font-weight: 700"><b><font size="2">
Signage </font></b>
<input type="checkbox" name="check[]" value="wrapping" style="font-weight: 700"><b><font size="2">
Vehicle Wrapping<br></font></b>
<input type="checkbox" name="check[]" value="Stickers" style="font-weight: 700"><b><font size="2">
Stickers/Labels </font></b>
<input type="checkbox" name="check[]" value="banners" style="font-weight: 700"><b><font size="2">
Banners/Posters/WallArt</font></b></font><b><font size="2"><br>
</font><font size="1">
<br>
</font><font size="2">
<input type="submit" value="Send">
<input type="reset" value="Clear">
</form>
php code im using:
<html><body>
<?php
$field_answer = $_POST['cf_answer'];
$field_name = $_POST['cf_name'];
$field_company = $_POST['cf_company'];
$field_email = $_POST['cf_email'];
foreach($_POST['check'] as $value) {
$check_boxes .= $value." ";
}
$mail_to = 'test@test.com';
$mail_subject = 'Competition Entry '.$field_name;
$body_message = 'Answer: '.$field_answer."\n";
$body_message .= 'From: '.$field_name."\n";
$body_message .= 'Company: '.$field_company."\n";
$body_message .= 'Email: '.$field_email."\n";
$body_message .= "Products and Services: ".$check_boxes;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $mail_subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
message('We have received your entry');
window.location = '';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to test@test.com');
window.location = '';
</script>
<?php
}
?>
</body>
</html>