I have an ajax-register.php
include("connection.php");
if($_POST)
{
//form data
$fname = mysql_real_escape_string($_POST['fname']);
$lname = mysql_real_escape_string($_POST['lname']);
$password = md5(mysql_real_escape_string($_POST['password']));
$confimPass = md5(mysql_real_escape_string($_POST['confirmPass']));
$email = mysql_real_escape_string($_POST['email']);
$confirmEmail = mysql_real_escape_string($_POST['confirmEmail']);
$dob = mysql_real_escape_string($_POST['dob']);
// database
$queryreg = ("INSERT INTO users (fname,lname,password,email,dob) VALUES ('$fname','$lname','$password','$email','$dob'");
mysql_query($queryreg) or die(mysql_error());
}
Then I have my register.php with my form and ajax code
<script type="text/javascript">
$(document).ready(function() {
$("a#register").click(function(){
var fname = $('input#fname').attr('value');
var lname = $('input#lname').attr('value');
var email = $('input#email').attr('value');
var password = $('input#password').attr('value');
var dob = $('input#dob').attr('value');
if(fname=='' || lname==''|| email==''||password==''){
$('.error').fadeOut(800).show();
}else{
$.ajax({
type: "POST",
url: "includes/ajax-register.php",
data: "fname="+fname+"& lname="+lname+"& email="+email+"& password"+ dob,
success: function(){
$('.success').show();
}
});
}
return false;
});
});
<script>
<body>
<form name="register" id="register" method="post">
<input id="fname"/>
<input id="lname"/>
<input id="password"/>
<input id="email"/>
<input id="dob"/>
<a href="#" id="register" name="register" onClick="document.forms['register'].submit();">register</a>
</form>
<span class="success" style="display:none;">Success</span>
<span class="error" style="display:none;">Error</span>
</body>
I'm getting Errors displayed if I didn't input anything, and I'm getting Success displayed if I did input my information. However, its not inputing into my database?
Can someone help?
Thank you!