Firstly Hello all, im new to server-side and to php and the functionality behind feedback forms - i delt with pearl a while back for a feedback form and got quite burnt by the experience, so…
Anyway, ive cobbled together some code from kirupas really good tutorial section - http://www.kirupa.com/web/form_mailer.htm - and it works excellently…
<?PHP
$to = "@gmail.com";
$date = date ("l, F jS, Y");
$time = date ("h:i A");
$subject = "Results from your Request Info form";
$headers = "From: you";
$forward = 0;
$msg = "Below is the result of your feedback form. It was submitted on $date at $time.
";
if ($_SERVER['REQUEST_METHOD'] == "POST") {
foreach ($_POST as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "
";
}
}
else {
foreach ($_GET as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "
";
}
}
mail($to, $subject, $msg, $headers);
if ($forward == 1) {
header ("Location:$location");
}
else {
echo "Thank you for submitting our form. A representative will get back to you as soon as possible.";
}
?>
but i need to ‘validate’(?) or see that the user has inputted the correct or any data ie: *required fields type thing. If they dont input anythikng or the correct thing (like @ in email box) then it shows an ‘error’ as a page or anything, and then doesnt send.
i also need 1 tick box - ‘yes’ if ticked, ‘no’ if unticked - again ‘validated’
thinking about it… is php even the best method for this?
thanks a lot!