tibewww Posted January 8, 2014 Share Posted January 8, 2014 Hi everybody ! I'm struggling since few days with that, I have a online quiz by jQuery, I want once the user submit it, to send the results with the contact information's of the users to the moderator. I make it work, sending the results information correctly, the problem is it doesn't send the user information. I've been playing around with different solution's, I can manage or to have the user information or the results of the quiz, but not both at the same time ! If anybody can highlight me, I will really be so thankful !!! Here is the "contact form": <div class="questionContainer radius hide"> <form action="submit.php" method="POST" id="form"> <label>Name</label> <input name="name" placeholder="Type Here"> <label>Email</label> <input name="email" type="email" placeholder="Type Here"> <label>Message</label> <textarea name="message" placeholder="Type Here"></textarea> <input id="button" type="submit" value="Send" class="btnShowResult"> </form> </div> <div class="txtStatusBar">Status Bar</div> <div id="progressKeeper" class="radius"> <div id="progress"></div> </div> <div id="resultKeeper" class="radius hide"></div> </div> Here is the jQuery part about the ajax to send the data result of the quiz, the div #resultKeeper being the result I want to receive $(function() { $('#form').on('submit',function(e) { e.preventDefault(); $.ajax({ url:'submit.php', type:'POST', data:{'results':$('#resultKeeper').html(),'subject':'Subject of your e-mail'}, success:function() { $('#responseMessage').html() } }); return false; }); }); here is my PHP <?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $results = $_POST['results']; $formcontent="From: $name \n Message: $message \n Results: \n $results"; $recipient = "[email protected]"; $subject = "my subject"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); echo "Your email has been send, thank you"; ?> If in the Jquery I change the $(function() { $('#form').on('submit',function(e) by #button instead of #form, I receive the informations from the contact form, but not anymore from the results. Also by keepin the #form, I receive the result of the quiz, and few value as the form content, but not the informations from the placeholder !, here is what I receive by email: " From: Message: Results: Question 1 is true Question 2 is false Question 3 is true Question 4 is false Question 5 is falseYour total score is 2 / 5CONGRATULATION, YOUR LEVEL IS A1.1 As we can see I have the From: and Message: appearing, but not the proper name and message that the user are writting .. . Anyhelp will be adorable !! Here is the allcode of JSFiddle: http://jsfiddle.net/ccwJJ/ Thank you in advance !! Link to comment https://forums.phpfreaks.com/topic/285210-data-submit-with-ajax-get-result-but-not-contact-form/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.