Does PHP skip requests when they come in quickly/skip over blocks of the code?

The above explanation is all I could give for the behavior I have been seeing. What I want to happen:

User starts typing in username or email text box then to the right of it says: Not enough characters, invalid, or valid.

What happens:
User starts typing, says not enough characters. User keeps typing, always says not enough characters.

I added a time() function at the end and the time does in fact update, just not the first part where it tells you the important info. It’s called from a javascript function with the “onkeyup” event.

Client-Side:

[code]

My Second Test Site Username:
Password:
E-Mail:
Gender: Male Female
Date of Birth:
[/code]

Server-Side:
[php]<?php
$do = $_POST[‘do’];
$q = $_POST[‘q’];
$con = mysql_connect(‘localhost’, ‘root’, ‘g0dRawR17’);
mysql_select_db(‘websites’);
if($do == ‘username’){
$result = mysql_query(“SELECT * FROM site2_users WHERE username = ‘$q’”);
echo mysql_error();
if(mysql_numrows($result) > 0){
echo ‘Username already taken!’;
}else{
//Again, it would be easy to simply this stuff, but as of now, please just ignore it.
echo ‘Username available!’;
}
}else if($do == ‘email’){
$result = mysql_query(“SELECT * FROM site2_users WHERE email = ‘$q’”);
if(mysql_numrows($result) > 0){
echo ‘Email already taken!’;
}else{
echo ‘Email available!’;
}
}
mysql_close($con);
echo ’ ’ . time();
?>[/php]

I got a few points you might want to change.

[ul][li]I see you use jQuery, use this for ajax request aswell? makes it much more easy: http://api.jquery.com/jQuery.ajax/[/li]
[li]Your using the id tag with the same values on different opperators, ID in html/css/javascript are unique identifiers. this might cause some trouble in different browsers.[/li][/ul]

[li]And your using the e as value which isn’t true. the e is an event given to the function. what you might do is use this:
[/li][/list]var value = $(this).val()
[ul]and instead of giving e to the post use value instead.[/li][/ul]

Hope your taking use of the tips and my solution works. :smiley:

Sponsor our Newsletter | Privacy Policy | Terms of Service