first off thank you in advance. I am writing a sign up page in PHP and using Jquery Validate to check the form. It is returning errors when the form is filled out incorrectly, but when it is correctly filled out it is just refreshed and not completing the actions I have delegated in the isset $_POST function. Here is what I am dealing with:
PHP If form is not empty
//Escape high risk symbols
$pw= mysqli_real_escape_string($con, $_POST['pass']);
$username= mysqli_real_escape_string($con, $_POST['pass']);
$email = mysqli_real_escape_string($con, $_POST['email']);
$sex = mysqli_real_escape_string($con, $_POST['sex']);
$signedUp = date("Y-m-d H:i:s");
$hash = password_hash($pw, PASSWORD_DEFAULT);
echo 'Email: '.$email;
echo 'Username: '.$username;
echo 'Sex: '.$sex;
echo 'Signed Up: '.$signedUp;
}
?>
Here is the Form
<form method="post" class="form-signin" id="signup" name="signup">
...
</form>
Here is my validation javascript, it seems that it is not posting
<script src="js/formValidate.js"></script>
<script>
// When the document is ready
$(document).ready(function () {
//validation rules
$("#signup").validate({
onkeyup: false,
onfocusout: false,
errorElement: "div",
errorPlacement: function(error, element) {
error.appendTo("div#errors");
},
rules: {
email: {
required : true,
email: true
//equalTo: "#example3-field2"
},
username: {
required: true,
minlength: 5
},
pass: {
required : true,
minlength: 5
},
cPass: {
required : true,
equalTo : "#pass"
},
sex: {
required : true
},
},
messages: {
email: {
required: "You must enter an email address",
email: "Enter a valid email address"
//equalTo: "Field 1 must be equal to Field 2"
},
username: {
required: "You must choose a username",
minlength: "Username must be a minimum of 5 characters"
},
pass: {
required : "You are required to enter a password!",
minlength : "Password must be at least 5 characters!"
},
cPass : {
required : "You are required confirm your password!",
equalTo : "Passwords do not match"
},
sex : {
required : "You are required to choose a sex"
},
},
submitHandler: function(form) {
form.submit();
}
});
});
</script>