Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [jQuery] AJAX Contact Form
Forum PHP.pl > Forum > XML, AJAX
MFrost
Znalazłem taki oto skrypcik

http://midmodesign.com/downloads/ajaxcontactformv1.zip

strona projektu

http://midmodesign.com/news/coding/jquery-...-with-honeypot/

zmieniłem adres email na swój, ale niestety nie dostaję wiadomości po wypełnieniu formularza, skrypt wgrałem tutaj

http://www.zespolgips.pl/ajax/

w czym tkwi problem?
GameMaker
Funkcja mail() , może być wyłączona na serwerze , jeśli to stoi na shared hostingu , a najlepiej pokaż swój edytowany kod odpowiedzialny za wysyłkę e-mail.
MFrost
  1. <?php
  2. /*
  3.  
  4. This script was created by Bryan Helmig at midmodesign.com. It is licensed under http://creativecommons.org/licenses/by-nc-sa/3.0/us/.
  5. 1) A quick primer: place this on your server. Create a form like below:
  6. --------------------------------------------------------------------------------------------------------
  7. <form action="sendmail.php" method="post" id="contactForm">
  8. <p>Name:</p> <input type="text" name="name" value="" id="name" />
  9. <p>Email:</p> <input type="text" name="email" value="" id="email" />
  10. <p>Telephone:</p> <input type="text" name="tele" value="" id="tele" />
  11. <span style="display:none;"><p>Honeypot:</p> <input type="text" name="last" value="" id="last" /></span>
  12. <p>Message:</p> <textarea rows="5" name="message"></textarea>
  13. <input type="submit" value="Send Message" />
  14. </form
  15. --------------------------------------------------------------------------------------------------------
  16. 2) This will work fine for a standard form. If you want ajax power, add this div above or below and hide it with css.
  17. --------------------------------------------------------------------------------------------------------
  18. <div class="message"><div id="alert"></div></div>
  19. --------------------------------------------------------------------------------------------------------
  20. 3) And add this to the head: Also download jquery-latest.pack.js and jquery.form.js and point to those appropriately.
  21. --------------------------------------------------------------------------------------------------------
  22. <script type="text/javascript" src="jquery-latest.pack.js"></script>
  23. <script type="text/javascript" src="jquery.form.js"></script>
  24. <script type="text/javascript">
  25. $(document).ready(function() {
  26. var options = {
  27. target: '#alert',
  28. beforeSubmit: showRequest,
  29. success: showResponse
  30. };
  31. $('#contactForm').ajaxForm(options);
  32. });
  33. function showRequest(formData, jqForm, options) {
  34. var queryString = $.param(formData);
  35. return true;
  36. }
  37. function showResponse(responseText, statusText) {
  38. }
  39. $.fn.clearForm = function() {
  40.   return this.each(function() {
  41. var type = this.type, tag = this.tagName.toLowerCase();
  42. if (tag == 'form')
  43. return $(':input',this).clearForm();
  44. if (type == 'text' || type == 'password' || tag == 'textarea')
  45. this.value = '';
  46. else if (type == 'checkbox' || type == 'radio')
  47. this.checked = false;
  48. else if (tag == 'select')
  49. this.selectedIndex = -1;
  50.   });
  51. };
  52. </script>
  53. --------------------------------------------------------------------------------------------------------
  54.  
  55. Boom. There it is.
  56. */
  57.  
  58. // Who you want to recieve the emails from the form. (Hint: generally you.)
  59. $sendto = 'netmroz@o2.pl';
  60.  
  61. // The subject you'll see in your inbox
  62. $subject = 'Contact from contact form';
  63.  
  64. // Message for the user when he/she doesn't fill in the form correctly.
  65. $errormessage = 'Oops! There seems to have been a problem. May we suggest...';
  66.  
  67. // Message for the user when he/she fills in the form correctly.
  68. $thanks = "Thanks for the email! We'll get back to you as soon as possible!";
  69.  
  70. // Message for the bot when it fills in in at all.
  71. $honeypot = "You filled in the honeypot! If you're human, try again!";
  72.  
  73. // Various messages displayed when the fields are empty.
  74. $emptyname = 'Entering your name?';
  75. $emptyemail = 'Entering your email address?';
  76. $emptytele = 'Entering your telephone number?';
  77. $emptymessage = 'Entering a message?';
  78.  
  79. // Various messages displayed when the fields are incorrectly formatted.
  80. $alertname = 'Entering your name using only the standard alphabet?';
  81. $alertemail = 'Entering your email in this format: <i>name@example.com</i>?';
  82. $alerttele = 'Entering your telephone number in this format: <i>555-555-5555</i>?';
  83. $alertmessage = "Making sure you aren't using any parenthesis or other escaping characters in the message? Most URLS are fine though!";
  84.  
  85. // --------------------------- Thats it! don't mess with below unless you are really smart! ---------------------------------
  86.  
  87. //Setting used variables.
  88. $alert = '';
  89. $pass = 0;
  90.  
  91. // Sanitizing the data, kind of done via error messages first. Twice is better! ;-)
  92. function clean_var($variable) {
  93. $variable = strip_tags(stripslashes(trim(rtrim($variable))));
  94. return $variable;
  95. }
  96.  
  97. //The first if for honeypot.
  98. if ( empty($_REQUEST['last']) ) {
  99.  
  100. // A bunch of if's for all the fields and the error messages.
  101. if ( empty($_REQUEST['name']) ) {
  102. $pass = 1;
  103. $alert .= "<li>" . $emptyname . "</li>";
  104. } elseif ( ereg( "[][{}()*+?.\\^$|]", $_REQUEST['name'] ) ) {
  105. $pass = 1;
  106. $alert .= "<li>" . $alertname . "</li>";
  107. }
  108. if ( empty($_REQUEST['email']) ) {
  109. $pass = 1;
  110. $alert .= "<li>" . $emptyemail . "</li>";
  111. } elseif ( !eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $_REQUEST['email']) ) {
  112. $pass = 1;
  113. $alert .= "<li>" . $alertemail . "</li>";
  114. }
  115. if ( empty($_REQUEST['tele']) ) {
  116. $pass = 1;
  117. $alert .= "<li>" . $emptytele . "</li>";
  118. } elseif ( !ereg( "\(?[0-9]{3}\)?[-. ]?[0-9]{3}[-. ]?[0-9]{4}", $_REQUEST['tele'] ) ) {
  119. $pass = 1;
  120. $alert .= "<li>" . $alerttele . "</li>";
  121. }
  122. if ( empty($_REQUEST['message']) ) {
  123. $pass = 1;
  124. $alert .= "<li>" . $emptymessage . "</li>";
  125. } elseif ( ereg( "[][{}()*+?\\^$|]", $_REQUEST['message'] ) ) {
  126. $pass = 1;
  127. $alert .= "<li>" . $alertmessage . "</li>";
  128. }
  129.  
  130. //If the user err'd, print the error messages.
  131. if ( $pass==1 ) {
  132.  
  133. //This first line is for ajax/javascript, comment it or delete it if this isn't your cup o' tea.
  134. echo "<script>$(\".message\").hide(\"slow\").show(\"slow\"); </script>";
  135. echo "<b>" . $errormessage . "</b>";
  136. echo "<ul>";
  137. echo $alert;
  138. echo "</ul>";
  139.  
  140. // If the user didn't err and there is in fact a message, time to email it.
  141. } elseif (isset($_REQUEST['message'])) {
  142.  
  143. //Construct the message.
  144. $message = "From: " . clean_var($_REQUEST['name']) . "\n";
  145. $message .= "Email: " . clean_var($_REQUEST['email']) . "\n";
  146. $message .= "Telephone: " . clean_var($_REQUEST['tele']) . "\n";
  147. $message .= "Message: \n" . clean_var($_REQUEST['message']);
  148. $header = 'From:'. clean_var($_REQUEST['email']);
  149.  
  150. //Mail the message - for production
  151. //mail($sendto, $subject, $message, $header);
  152. //This is for javascript,
  153. echo "<script>$(\".message\").hide(\"slow\").show(\"slow\").animate({opacity: 1.0}, 4000).hide(\"slow\"); $(':input').clearForm() </script>";
  154. echo $thanks;
  155. die();
  156.  
  157. //Echo the email message - for development
  158. echo "<br/><br/>" . $message;
  159.  
  160. }
  161.  
  162. //If honeypot is filled, trigger the message that bot likely won't see.
  163. } else {
  164. echo "<script>$(\".message\").hide(\"slow\").show(\"slow\"); </script>";
  165. echo $honeypot;
  166. }
  167. ?>
  168.  
  169.  



hosting jest płatny

mam jeszcze drugi inny formularz pod tym adresem, na tym samym serwerze i koncie

http://www.zespolgips.pl/contact/contact.htm

kod php
  1. <?php
  2. if(isset($_POST['submit'])) {
  3.  
  4. $to = "netmroz@o2.pl";
  5. $subject = "Form Tutorial";
  6. $name_field = $_POST['name'];
  7. $email_field = $_POST['email'];
  8. $message = $_POST['message'];
  9. $option = $_POST['radio'];
  10. $dropdown = $_POST['drop_down'];
  11.  
  12. foreach($_POST['check'] as $value) {
  13. $check_msg .= "Checked: $value\n";
  14. }
  15.  
  16. $body = "From: $name_field\n E-Mail: $email_field\n $check_msg Option: $option\n Drop-Down: $dropdown\n Message:\n $message\n";
  17.  
  18. echo "Data has been submitted to $to!";
  19. mail($to, $subject, $body);
  20.  
  21. } else {
  22. echo "blarg!";
  23. }
  24. ?>


i tutaj formularz działa, dostaje maila z wiadomością z formularza
markonix
Czy ja jestem ślepy albo funkcja mail jest zakomentowana? ....
MFrost
czy chodzi Ci o 151 linię? właśnie ją odkomentowałem wrzuciłem poprawkę na serwer i nadal lipa


ok dzięki wielkie za podpowiedź, już wszystko działa, pozro:)
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.