Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Edycja skryptu wysylki maila
Forum PHP.pl > Forum > PHP
Metalowy
Witam serdecznie.
Wiec, ostatnio chcialem sobie zrobic na stronie formularz wysylajacy maila do mnie. A ze znam tylko html to polecialem ze zleceniem znalezienia skryptu do google. Wszystko ladnie fajnie dziala, ale teraz chce go edytowac jak zlikwidowac pola Full Name, Telephone Number i Your_Message. Bylbym wdzieczny za edycje. Pozdrawiam.




  1. <?php
  2. if(isset($_POST['Email_Address'])) {
  3.  
  4. include 'lite_settings.php';
  5.  
  6. if($email_to == "youremailaddress@yourdomain.com") {
  7. die("This message is for the Webmaster. Please enter your email address into the file 'lite_settings.php'");
  8. }
  9.  
  10. function died($error) {
  11. echo "Sorry, but there were error(s) found with the form your submitted. ";
  12. echo "These errors appear below.<br /><br />";
  13. echo $error."<br /><br />";
  14. echo "Please go back and fix these errors.<br /><br />";
  15. die();
  16. }
  17.  
  18. if(!isset($_POST['Full_Name']) ||
  19. !isset($_POST['Email_Address']) ||
  20. !isset($_POST['Telephone_Number']) ||
  21. !isset($_POST['Your_Message'])) {
  22. died('We are sorry, but there appears to be a problem with the form your submitted.');
  23. }
  24.  
  25. $full_name = $_POST['Full_Name']; // required
  26. $email_from = $_POST['Email_Address']; // required
  27. $telephone = $_POST['Telephone_Number']; // not required
  28. $comments = $_POST['Your_Message']; // required
  29.  
  30. $error_message = "";
  31. $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
  32. if(!eregi($email_exp,$email_from)) {
  33. $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  34. }
  35. if(strlen($full_name) < 2) {
  36. $error_message .= 'Your Name does not appear to be valid.<br />';
  37. }
  38. if(strlen($comments) < 2) {
  39. $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  40. }
  41.  
  42. if(strlen($error_message) > 0) {
  43. died($error_message);
  44. }
  45. $email_message = "Form details below.\r\n";
  46.  
  47. function clean_string($string) {
  48. $bad = array("content-type","bcc:","to:","cc:","href");
  49. return str_replace($bad,"",$string);
  50. }
  51.  
  52. $email_message .= "Full Name: ".clean_string($full_name)."\r\n";
  53. $email_message .= "Email: ".clean_string($email_from)."\r\n";
  54. $email_message .= "Telephone: ".clean_string($telephone)."\r\n";
  55. $email_message .= "Message: ".clean_string($comments)."\r\n";
  56.  
  57. $headers = 'From: '.$email_from."\r\n".
  58. 'Reply-To: '.$email_from."\r\n" .
  59. 'X-Mailer: PHP/' . phpversion();
  60. @mail($email_to, $email_subject, $email_message, $headers);
  61. header("Location: $thankyou");
  62. ?>
  63. <script>location.replace('<?php echo $thankyou;?>')</script>
  64. <?
  65. }
  66. ?>
bobo168
  1. <?php
  2. if(isset($_POST['Email_Address'])) {
  3.  
  4. include 'lite_settings.php';
  5.  
  6. if($email_to == "youremailaddress@yourdomain.com") {
  7. die("This message is for the Webmaster. Please enter your email address into the file 'lite_settings.php'");
  8. }
  9.  
  10.  
  11. $email_from = $_POST['Email_Address']; // required
  12.  
  13. $error_message = "";
  14. $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
  15. if(!eregi($email_exp,$email_from)) {
  16. $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  17. }
  18. if(strlen($full_name) < 2) {
  19. $error_message .= 'Your Name does not appear to be valid.<br />';
  20. }
  21. if(strlen($comments) < 2) {
  22. $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  23. }
  24.  
  25. if(strlen($error_message) > 0) {
  26. died($error_message);
  27. }
  28. $email_message = "Form details below.\r\n";
  29.  
  30. function clean_string($string) {
  31. $bad = array("content-type","bcc:","to:","cc:","href");
  32. return str_replace($bad,"",$string);
  33. }
  34.  
  35. ;
  36. $email_message .= "Email: ".clean_string($email_from)."\r\n";
  37.  
  38. $headers = 'From: '.$email_from."\r\n".
  39. 'Reply-To: '.$email_from."\r\n" .
  40. 'X-Mailer: PHP/' . phpversion();
  41. @mail($email_to, $email_subject, $email_message, $headers);
  42. header("Location: $thankyou");
  43. ?>
  44. <script>location.replace('<?php echo $thankyou;?>')</script>
  45. <?
  46. }
  47. ?>


powinno działac..
Metalowy
Teraz zamiast otierac trone thankyou, po wyslaniu formularza, kieruje do tego pliku php blinksmiley.gif
bobo168
Z 41 linijki sprzed funkcji mail(); usuń @ i napisz czy coś wyskoczyło jak tak to skopiuj i pokaż.
Metalowy
Nic nie wyskoczylo, jest to samo

Moze cos w htmlu zwalilem bo tez go edytowalem zeby pozbyc sie pol

Bylo
  1. <!--
  2. ///test test test
  3. -->
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7. <title>Contact Us</title>
  8. <script src="lite_validation.js"></script>
  9. required.add('Full_Name','NOT_EMPTY','Full Name');
  10. required.add('Email_Address','EMAIL','Email Address');
  11. required.add('Your_Message','NOT_EMPTY','Your Message')
  12. </script>
  13. <link rel="stylesheet" type="text/css" href="lite_styles.css">
  14. </head>
  15. <body>
  16.  
  17. <form name="contactformlite" method="post" action="lite_process.php" onsubmit="return validate.check(this)">
  18. <table width="400px" class="cflite">
  19. <tr>
  20. <td colspan="2">
  21. <p style="text-align:center">Fields marked with <span class="required_star"> * </span> are required.</p>
  22. </td>
  23. </tr>
  24. <tr>
  25. <td valign="top" class="cflite_td">
  26. <label for="Full_Name" class="required">Full Name<span class="required_star"> * </span></label>
  27. </td>
  28. <td valign="top" class="cflite_td">
  29. <input type="text" name="Full_Name" id="Full_Name" maxlength="80" style="width:250px">
  30. </td>
  31. </tr>
  32. <tr>
  33. <td valign="top" class="cflite_td">
  34. <label for="Email_Address" class="required">Email Address<span class="required_star"> * </span></label>
  35. </td>
  36. <td valign="top" class="cflite_td">
  37. <input type="text" name="Email_Address" id="Email_Address" maxlength="100" style="width:250px">
  38. </td>
  39. </tr>
  40. <tr>
  41. <td valign="top" class="cflite_td">
  42. <label for="Telephone_Number" class="not-required">Telephone Number</label>
  43. </td>
  44. <td valign="top" class="cflite_td">
  45. <input type="text" name="Telephone_Number" id="Telephone_Number" maxlength="100" style="width:250px">
  46. </td>
  47. </tr>
  48. <tr>
  49. <td valign="top" class="cflite_td">
  50. <label for="Your_Message" class="required">Your Message<span class="required_star"> * </span></label>
  51. </td>
  52. <td valign="top" class="cflite_td">
  53. <textarea style="width:250px;height:120px" name="Your_Message" id="Your_Message" maxlength="2000"></textarea>
  54. </td>
  55. </tr>
  56. <tr>
  57. <td colspan="2" style="text-align:center" class="cflite_td">
  58. <input type="submit" value="Submit">
  59. <br /><br />
  60. <!-- LEGAL NOTICE: YOU MUST KEEP THIS LINK UNCHANGED -->
  61. This form is powered by <a href="http://www.freecontactform.com/">Free Contact Form</a>
  62. <!-- LEGAL NOTICE: YOU MUST KEEP THIS LINK UNCHANGED -->
  63. <br /><br />
  64. </td>
  65. </tr>
  66. </table>
  67. </form>
  68. </body>
  69. </html>



Jest
  1. <!--
  2. // test test test
  3. -->
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7. <title>Contact Us</title>
  8. <script src="lite_validation.js"></script>
  9. required.add('Email_Address','EMAIL','Email Address')
  10. </script>
  11. <link rel="stylesheet" type="text/css" href="lite_styles.css">
  12. </head>
  13. <body>
  14.  
  15. <form name="contactformlite" method="post" action="lite_process.php" onsubmit="return validate.check(this)">
  16. <table width="400px" class="cflite">
  17. <tr>
  18. <td valign="top" class="cflite_td">
  19. <label for="Email_Address" class="required">Email Address<span class="required_star"> * </span></label>
  20. </td>
  21. <td valign="top" class="cflite_td">
  22. <input type="text" name="Email_Address" id="Email_Address" maxlength="100" style="width:250px">
  23. </td>
  24. </tr>
  25. <tr>
  26. <td colspan="2" style="text-align:center" class="cflite_td">
  27. <input type="submit" value="Submit">
  28. <br /><br />
  29. <!-- LEGAL NOTICE: YOU MUST KEEP THIS LINK UNCHANGED -->
  30. This form is powered by <a href="http://www.freecontactform.com/">Free Contact Form</a>
  31. <!-- LEGAL NOTICE: YOU MUST KEEP THIS LINK UNCHANGED -->
  32. <br /><br />
  33. </td>
  34. </tr>
  35. </table>
  36. </form>
  37. </body>
  38. </html>
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.