Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 1.85 KB  |  hits: 28  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. PHP mail function doesn't work with jQuery validation plugin
  2. $(document).ready(function(){
  3.     $("form").validate({
  4.     submitHandler: function() {
  5.         alert("Thank you for submitting your information.");
  6.         },
  7.     });
  8. });
  9. <form class="cmxform" id="myform" method="post" action="contact.php">
  10.     <fieldset>
  11.         <p><label for="cname">Name:</label> <input type="text" id="cname" name="name" maxlength="255" class="required" /></p>
  12.         <p><label for="cemail">Email:</label> <input type="text" id="cemail" name="email" maxlength="255" class="required email" /></p>
  13.         <p><label for="tel">Tel:</label> <input type="text" id="tel" name="tel" maxlength="15" class="required" /></p>
  14.         <p><label for="service">Service:</label>
  15.             <select name="service">
  16.                 <option value="option1">Option1</option>
  17.                 <option value="option2">Option2</option>
  18.                 <option value="option3">Option3</option>
  19.             </select>
  20.         </p>
  21.         <p><label for="comments">Comments:</label><textarea class="textarea" id="comments" name="comments" rows="7" cols="1"></textarea></p>
  22.  
  23.         <input type="submit" name="submit" class="button" value="Submit" />
  24.     </fieldset>
  25. </form>
  26.        
  27. <?php
  28. if(isset($_POST['submit']))
  29. {
  30. $name = $_POST['name'];
  31. $email = $_POST['email'];
  32. $tel = $_POST['tel'];
  33. $service = $_POST['service'];
  34. $comments = $_POST['comments'];
  35.  
  36. $header='From: '.$email."rn";
  37. $header.='Content-Type: text/plain; charset=utf-8';
  38.  
  39. $msg='Message from: '.$name."rn";
  40. $msg.='Email: '.$email."rn";
  41. $msg.='Tel: '.$tel."rn";
  42. $msg.='Interested in: '.$service."rn";
  43. $msg.='Message: '.$comments."rn";
  44. $msg.='Sent '.date("d/m/Y",time());
  45. $msg.=utf8_decode('');
  46.  
  47. $to = 'example@hotmail.com, example@gmail.com, example@company.com';
  48. $subject = 'Contact from website';
  49.  
  50. mail($to,$subject,$msg,$header);
  51. }
  52.  
  53. header("Location: contact.html");
  54. ?>