PHP 36
Perfect-v2.1.1.php Guest on 5th June 2020 10:47:05 AM
  1. <?php
  2. ///////////////////////////////////////////////////////
  3. // PERFECT PHP                                       //
  4. // v2.1.1 (September 16, 2018)                       //
  5. // Process a web form to extract the user input and  //
  6. //    then email the data to a predefined recipient. //
  7. // MIT License or WTFPL (your choice)                //
  8. // https://centerkey.com/php                         //
  9. ///////////////////////////////////////////////////////
  10.  
  11. // Configuration settings
  12. $sendFrom =    "Form Feedback <[email protected]>";
  13. $sendTo =      "[email protected]";
  14. $subjectLine = "Feedback Submission";
  15. $thanksUrl =   "thanks.html";  //confirmation page
  16.  
  17. // Build message body from web form input
  18. $body = $_SERVER["SERVER_NAME"] . PHP_EOL . PHP_EOL;
  19. foreach ($_POST as $field=>$value)
  20.    $body .= "$field: $value" . PHP_EOL;
  21. $body .= PHP_EOL . @gethostbyaddr($_SERVER["REMOTE_ADDR"]);
  22. $body = htmlspecialchars($body, ENT_NOQUOTES);  //make safe
  23.  
  24. // Send email and direct browser to confirmation page
  25. mail($sendTo, $subjectLine, $body, "From: $sendFrom");
  26. header("Location: $thanksUrl");
  27. ?>

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.