I'm working on a jQuery-powered registration form, and I'm checking all the input with jQuery, and the only thing left is to see if a user is choosing an already-registered name.
Here's my Ajax request:
$.ajax({
type: "POST",
url: "check_user.php",
data: "username="+username,
success: function(){
errors.push('Your username is taken.');
}
});
And check_user.php:
<?php
include_once('../lib/config.php');
$username = $_POST['username'];
$query = mysql_query("SELECT * FROM `users` WHERE `username` = '$username'");
if(mysql_num_rows($query) == 1) {
header("HTTP/1.1 200 OK");
}
?>
I know the errors.push(); works, because when I was trying to figure out what was wrong with the Ajax request earlier, the 'Username is taken' message was showing up on my registration page whenever I click 'Register'. Now nothing is showing up at all.
Here's all my whole registration page: http://pastebin.org/66815
UPDATE:
The file (signup.php) is located at C:\xampp\htdocs\register\user\signup.php
I was using .htaccess and RewriteRule ^signup user/signup.php
and viewing it at http://localhost/signup. When I remove that RewriteRule and got to http://localhost/register/user/signup.php, everything works fine.
So I change url: "check_user.php"
to "url: user/check_user.php"
and it all works fine. I didn't know .htaccess was that badass.