I have a online questionnaires that I've link with a submit form, towards to send the infos of the user with the result to my email. It's work fine.
The only thing is that right now, the people can submit the result of the quizz without completing their personnal informations.
If you can help me with this, it will be wonderfull, What i would like, it that persons have to obligatory to complete their infos ( names,email,etc) to submit the results =).
I really appreciate your time,
Here is my Js, Where the #quesForm are the results, and the #responseMessage an other info that needs to be send :
$(function() {
$('#quesForm').on('submit',function(e) {
e.preventDefault();
var uname = $("input[name=username]").val();
var uemail = $("input[name=email]").val();
var msg = $("input[name=message]").val()
$.post('submit.php',{username:uname,email:uemail,message:msg,results:$('#resultKeeper').html(),subject:'Subject of your e-mail'},function(result){
$('#responseMessage').html(result);
});
});
Here is my submit.php
<?php $name = $_POST['username'];
$email = $_POST['email'];
$message = $_POST['message'];
$results = $_POST['results'];
$results = strip_tags($results); // add this to remove html tags and all
$formcontent="From: $name
Email: $email
Phone: $message
Results:
$results";
$recipient = "email@email.com";
$subject = "subject of email";
$mailheader = "From: $email
";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "";
?>