Forum Moderators: coopster
Thanks.
Here is the code:
<?php
if ($_SERVER['REQUEST_METHOD']=="POST"){
// In testing, if you get an Bad referer error
// comment out or remove the next three lines
if (strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])>7 ¦¦
!strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']))
die("Bad referer");
$msg="Values submitted by the user:\n";
foreach($_POST as $key => $val){
if (is_array($val)){
$msg.="Item: $key\n";
foreach($val as $v){
$v = stripslashes($v);
$msg.=" $v\n";
}
} else {
$val = stripslashes($val);
$msg.="$key: $val\n";
}
}
$recipient="me@yahoo.com, me@example.com";
$subject="Contact Form";
error_reporting(0);
if (mail($recipient, $subject, $msg)){
echo "<center><h1>Thank you</h1><p>Message successfully sent!</p></center><br>\n";
echo nl2br($input);
} else
echo "An error occurred and the message could not be sent.";
} else
echo "Bad request method";
?>
[edited by: jatar_k at 10:13 pm (utc) on Aug. 25, 2006]
[edit reason]
[1][edit reason] generalized urls [/edit] [/edit][/1]
something like
<meta http-equiv="refresh" content="2;url=http://www.example.com/index.html">
where 2 would be the number of seconds to wait before the refresh
as far as changing the email format, it is just a matter of adding html to the foreach loops and probably changing the mail headers.
adding sessions would involve adding sessions to the rest of your site too, I imagine. This isn't hard but could be a fair amount of work. I would roll it out as is and then you can add sessions later if needed.
foreach($_POST as $key => $val){
if (is_array($val)){
$msg.="Item: $key\n";
foreach($val as $v){
$v = stripslashes($v);
$msg.=" $v\n";
}
} else {
$val = stripslashes($val);
$msg.="$key: $val\n";
}
} it builds it line by line, value by value, you just need to add html to the loop. Play around and see what looks good