c3118526 Posted October 10, 2006 Share Posted October 10, 2006 <?php//Collect the details from the form using $_GET server variable$name = $_GET["name"];$sname = $_GET["surname"];$email = $_GET["emailad"];$ad1 = $_GET["adline1"];$ad2 = $_GET["adline2"];$post = $_GET["postcode"];//Checking and Validation$errorString ="";if (empty($name)) { $errorString = "Enter your name<br>";}if (empty($sname)) { $errorString = "Enter your surname<br>";}if (empty($email)) { $errorString = $errorString. "Enter your email<br>";} if (empty($ad1)) { $errorString = $errorString. "Enter the first line of your address<br>";}if (empty($ad2)) { $errorString = $errorString. "Enter the second line of your address<br>";}if (empty($post)) { $errorString = $errorString. "Enter your postcode"; }//If there were errors - report them and exitif (!empty($errorString)){ $errorString = "<h3>There were errors</h3>".$errorString ; print $errorString; exit;}else { print "Thank you $name for requesting a copy of our catalogue <br> We have sent a copy of the information to your email address: $email";}$from = "Pet Planet <bethany_1@blueyonder.co.uk>";$to = "$email";$subject = "Catalogue request details";$body = "Hi $name, /n Thankyou for ordering our catalogue. It has been sent to the following address: /n $ad1 /n $ad2 /n $post";if (mail($to, $subject, $body)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); }?> Link to comment Share on other sites More sharing options...
justsomeguy Posted October 11, 2006 Share Posted October 11, 2006 What's the problem? If you want to know how to set the 'from' address, check the mail reference, it's there in example 2:http://www.php.net/manual/en/function.mail.phpAlso, you can shorten $errorString = $errorString . "..." to just $errorString .= "..."You also aren't validating the email address other then just testing if it is empty. If you want to use a regular expression to check whether or not the address is a valid format for an email address (i.e. xxx@xxx.xxx or xxx.xxx.xxx@xxx.xxx.xxx or whatever) then do a Google search for "PHP email address validation with regular expression".Otherwise, if you're getting some error message or something is happening that you aren't expecting, you need to say what it is. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now