| Feedback Form (PHP) Script |
| Thursday, 16 April 2009 | |
|
Scenario #1: Web Server's PHP version doesn't support $_REQUEST Solution: Use $_GET (NOTE: careful in using this method on sensitive transaction) Scenario #2: Web Server's execution time is set to 30sec (max), hence the error, Fatal error: Maximum execution time of 30 seconds on "http://....sendmail.php" Solution: set_time_limit(60) Saving and sharing my HTML/form code and sendmail.php here for my reference (took me a while to solve it, getting rusty na!). ******************************
<form method="get" action="sendmail.php"> <input type="text" name="name" value="Name:" />
<input type="text" name="mail" value="E-mail:" /> <textarea name="message" cols="30" rows="60">Message:</textarea> <input type="submit" /> </form> ****************************** <?php set_time_limit(60); $name = $_GET['name']; $email = $_GET['mail']; $message = $_GET['message']; if (empty($email) || empty($message)) { ?> <html> <head><title>Error</title></ <body> <h1>Error</h1> <p> Oops, it appears you forgot to enter either your email address or your message. Please press the BACK button in your browser and try again. </p> </body> </html> <?php } else { mail( " This e-mail address is being protected from spam bots, you need JavaScript enabled to view it ", "Feedback from your website", $message, "From: $name <$email>" ); // redirect back to url visitor came from or // header( "Location: http://www.yoursite.com/thankyou.html" ); header("Location: $HTTP_REFERER"); } ?> ****************************** |
| Next > |
|---|



I am Mae German. 34 years old. Born in Mangatarem, province of Pangasinan. I was taught and trained by 



