OK I've manged to generate a PHP form off some website, but I need to tweak it to my requirements
The code is as follows: -
PHP Code:
<?php
// Website Contact Form Generator
// http://www.tele-pro.co.uk/scripts/contact_form/
// This script is free to use as long as you
// retain the credit link
// get posted data into local variables
$EmailFrom = "nobody@example.com";
$EmailTo = "nobody@example.com";
$Subject = "subject subject";
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email']));
// validation
$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}
// prepare email body text
$Body = "";
$Body = "blah blah blah";
$Body .= "\n";
$Body .= "\n";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>
How do I get it to check that the form has been filled in correctly - and if it's not displaying an error message on screen. This form supposedly has error checking built in but it doesn't seem to work and you can type in nothing and it still says it's OK and sends a blank email.
Also, how do I get it to so that it gets IP address of the computer sending the form and the browser's user agent string so one can see what they're using - i.e. firefox/ie/opera/safari etc and pasts it in an email?
The current output in the emails is like this: -
Ideally I would like it to be like this: -
Quote:
blah blah blah
Name: ada
Email: dasdada
User agent: (UA string here)
IP address: (IP here)
|
I am not too knowledgeable on PHP, so if someone could rustle me up something then I'd be very grateful.
Thank you.