code is as follows:
HTML
-
<form action="../Prayer.php" method="post" name="frmPrayer" id="frmPrayer">
-
<div align="center"><strong>Enter your request in the box below and hit "send" to submit:</strong></div>
-
<center>
-
<textarea name="txtRequest" id="txtRequest" cols="100" rows="3"></textarea>
-
<br />
-
<br />
-
<div align="center"><strong>If you would like a reply, enter your e-mail or leave blank to remain anonymous:</strong></div>
-
<input name="txtReply" id="txtReply" type="text" size="60">
-
<br />
-
<br />
-
<input name="cmdSendReq" type="submit" value="Submit Request" onClick="<?php echo(sendMail()) ?>">
-
</center>
-
</form>
-
and php:
[php]
<?php
function sendMail()
{
$to = "user@example.com";
$subject = "New Online Prayer Request";
$message = $_POST['txtRequest'];
$txtReply = $_POST['txtReply'];
$headers = "To: Bloor Central Prayer" . "\r\n";
if($txtReply == "") {
$headers .= "From: user@example.com" . "\r\n";
} else {
$headers .= "From: ";
$headers .= $_POST['txtReply'] . "\r\n";
}
$headers .= "Cc: webmaster@example.com";
/*temp test - check all e-mails make it, spam*/
$sent = mail($to, $subject, $message, $headers);
if($sent)
{
echo "Message Sent Successfully";
} else {
echo "There Was an Error Sending Your Message";
}
}
?>
[/php]
Thanks all!