Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('#send').click(function(e){
- e.preventDefault();
- $.ajax({
- type: 'post',
- url: 'index.php',
- data: $('form').serialize(),
- success: function () {
- $('#contactForm').fadeOut(600);
- $('#contactClick').hide().html('Thanks for the message! I'll get back to you shortly.').fadeIn(600);
- $('section#contact').height(windowHeight);
- $('html, body').animate({scrollTop:($('#contact').position().top)}, 'slow');
- }
- });
- });
- <form id="myForm" action="index.php" method="post">
- <label class="col-xs-2">Name:</label>
- <input class="col-xs-12" id="name" type="text" name="name" autocomplete="off" />
- <label class="col-xs-2">Email:</label>
- <input class="col-xs-12" type="text" name="email" autocomplete="off" />
- <label class="col-xs-2">Message:</label>
- <textarea class="col-xs-12" id="message" rows="10" cols="10" autocomplete="off" name="message"></textarea>
- <input id="send" class="submit" type="submit" name="formSubmit" value="Send" />
- </form>
- <?php
- if($_POST['formSubmit']=="Send") {
- $to = "myemail@ddress.com";
- $subject = "A message from your website";
- $text = " Name: ";
- $text .= $_POST['name'];
- $text .= "rn";
- $text .= " E-mail: ";
- $text .= $_POST['email'];
- $text .= "rn";
- $text .= " Message: ";
- $text .= $_POST['message'];
- $text .= "rn";
- $wrapped_text = wordwrap($text, 120, "rn");
- $message = htmlentities($wrapped_text);
- mail($to,$subject,$message);
- }
- ?>
- <input id="send" class="submit" type="button" name="formSubmit" value="Send" />
- <form id="myForm">
- data: $('#myForm').serialize(),
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement