I've made a registration form and used jQuery Form Plugin (ajaxForm) to save the user input to my database. I validated the input fields using javascript in my HTML file, but I checked the email and username in my Php file.
But the problem is, I don't know how to show the echo message in my html file. Like when it echoes "Username is already in use", how can i show it in my html file (as an alert)?
My code is still not complete, I have put mysql_real_escape and encrypted the password using md5. I will do it after I solve my problem. \
Here is the code in saving the form to my database.
<script>
$(document).ready(function() {
var options = {
resetForm: true,
}
$('form#register').ajaxForm(options);
});
</script>
Here is part of my php file
//username validation
$user_check = mysql_query("SELECT uname FROM se_reg WHERE uname='$uname'");
$do_user_check = mysql_num_rows($user_check);
//email validation
$email_check = mysql_query("SELECT email FROM se_reg WHERE email='$email'");
$do_email_check = mysql_num_rows($email_check);
//error message for username and email
if($do_user_check > 0){
$mess = $json_encode('Username is already in use.');
die("$mess");
}
if($do_email_check > 0){
die("Email is already in use!");
}
database name: se table: se_reg