PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
what problem with tihs code?
this is a register code, i have 2 tables, account & account1, if i register a user, i don't want the 2 tables have the same username
I'm not sure about what jam said, because hes query is missing a few things. Hes calling to a field that is a variable (which is the username, could be basically anything), which just doesn't work.. This is what i use for checking the name:
$name_check = mysql_query("SELECT username FROM users WHERE username='$username'") or die(mysql_error());
if (mysql_num_rows($name_check) == 1) {
//name is taken
die();
} else {
//name is not taken
}
your script is work for one time only, when I register a user that the username currently not in the database, it can store in the database.
then if i back to the register page again and register another username, it always show me the name is taken.
when i register a name that currently in the database, it show me the username is taken, then i back to register page and register another username, it show me the username is taken although the username is not in the database.
Cant see the problem, or it's so obvious that I'm mising it...
You could, read the Passing Variables post (link in my signature) about using information from forms. Perhaps, just perhaps it can clear some issues (if the $username is somehow not renewed when you press back and retries).
For elseones reading, is this the IE6 bug with missing PRIVATE header?