Forum Moderators: coopster
Here is the PHP:
<?php
// Contact subject
$subject ="$subject";
// Details
$message="$detail";
// Mail of sender
$mail_from="$customer_mail";
// From
$header="from: $name <$mail_from>";
// Enter your email address
$to ='contact@example.com';
$send_contact=mail($to,$subject,$message,$header);
// Check, if message sent to your email
// display message "Thank you, we have recived your information."
if($send_contact){
echo "<meta http-equiv='refresh' content='0;url=http://www.example.com/thanks.html'>";
}
else {
echo "ERROR";
}
?>
Here is the Form:
<form name="form1" method="post" action="contact.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td width="16%"><font size ="2">Name</f></td>
<td><font size ="2">:</f></td>
<td width="82%"><input name="name" type="text" id="name" size="38"></td>
</tr>
<tr>
<td><font size ="2">Email</f></td>
<td><font size ="2">:</f></td>
<td><input name="customer_mail" type="text" id="customer_mail" size="38"></td>
</tr>
<tr>
<td><font size ="2">Website</f></td>
<td><font size ="2">:</f></td>
<td><input name="subject" type="text" id="subject" size="38"></td>
</tr>
THIS IS THE NEW PART THAT I WANT INCLUDED IN THE MESSAGE
<tr>
<td><font size ="2">Select Service</f></td>
<td><font size ="2">:</f></td>
<td><br><input type="radio" name="service" value="Item1"> Item #1
<br>
<input type="radio" name="service" value="Item2"> Item #2
<br>
<input type="radio" name="service" value="Item3"> Item #3</td>
</tr>
THIS IS THE CURRENT MESSAGE DETAIL
<tr>
<td><font size ="2">Detail</f></td>
<td><font size ="2">:</f></td>
<td><br><textarea name="detail" cols="30" rows="6" id="detail"></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><center><input type="submit" name="Submit" value="Send to example.com">
<br><br><input type="reset" name="Submit2" value="Reset"></center></td>
</tr>
</table>
</form>
</form>
[edited by: eelixduppy at 8:26 pm (utc) on Nov. 19, 2007]
[edit reason] example.com [/edit]
<?php
// Contact subject
$subject = $_POST['subject'];
// Details
$message = $_POST['detail'];
$message.= "\nService - $_POST['service']\n";
// Mail of sender
$mail_from = $_POST['customer_mail'];
// From
$header = "from: $name <$mail_from>";
// Enter your email address
$to ='contact@samplewebsite.com';
$send_contact = mail($to, $subject, $message, $header);
// Check, if message sent to your email
// display message "Thank you, we have recived your information."
if($send_contact){
// a posh redirecting script ;)
if (!headers_sent()) {
header ('Location: http://'.$_SERVER['HTTP_HOST'].'/thanks.html');
}
else {
echo "<script type=\"text/javascript\">
window.location.href=\"/thanks.html\";
</script>
<noscript>
<meta http-equiv='refresh' content='0;url=http://www.example.com/thanks.html'>";
</noscript>
}
}
else {
echo "ERROR";
}
?>
<edit>
put in a posh redirection script, as some antispam filters on browsers will stop both meta-refresh and window.location.href redirections, so it is better to do it at the server level. However to use the header function it will only work if no output has been sent, or if you output buffering turned on. So you need to check to see if headers have been sent.
[edited by: PHP_Chimp at 7:17 pm (utc) on Nov. 18, 2007]
[edited by: eelixduppy at 2:55 am (utc) on Nov. 19, 2007]
[edit reason] delinked [/edit]
When testing this revised script, I received this error message:
'Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /.../.../.../....php on line 6'
(I replaced what I thought may be secure info. with the ...)
Any clues on how to fix this?
Thanks.