- PHP mail function doesn't work with jQuery validation plugin
- $(document).ready(function(){
- $("form").validate({
- submitHandler: function() {
- alert("Thank you for submitting your information.");
- },
- });
- });
- <form class="cmxform" id="myform" method="post" action="contact.php">
- <fieldset>
- <p><label for="cname">Name:</label> <input type="text" id="cname" name="name" maxlength="255" class="required" /></p>
- <p><label for="cemail">Email:</label> <input type="text" id="cemail" name="email" maxlength="255" class="required email" /></p>
- <p><label for="tel">Tel:</label> <input type="text" id="tel" name="tel" maxlength="15" class="required" /></p>
- <p><label for="service">Service:</label>
- <select name="service">
- <option value="option1">Option1</option>
- <option value="option2">Option2</option>
- <option value="option3">Option3</option>
- </select>
- </p>
- <p><label for="comments">Comments:</label><textarea class="textarea" id="comments" name="comments" rows="7" cols="1"></textarea></p>
- <input type="submit" name="submit" class="button" value="Submit" />
- </fieldset>
- </form>
- <?php
- if(isset($_POST['submit']))
- {
- $name = $_POST['name'];
- $email = $_POST['email'];
- $tel = $_POST['tel'];
- $service = $_POST['service'];
- $comments = $_POST['comments'];
- $header='From: '.$email."rn";
- $header.='Content-Type: text/plain; charset=utf-8';
- $msg='Message from: '.$name."rn";
- $msg.='Email: '.$email."rn";
- $msg.='Tel: '.$tel."rn";
- $msg.='Interested in: '.$service."rn";
- $msg.='Message: '.$comments."rn";
- $msg.='Sent '.date("d/m/Y",time());
- $msg.=utf8_decode('');
- $to = 'example@hotmail.com, example@gmail.com, example@company.com';
- $subject = 'Contact from website';
- mail($to,$subject,$msg,$header);
- }
- header("Location: contact.html");
- ?>