Ok heres my problem. This is so when users sign up on my site; They type in the username they want, then php calls from mysql looking to see if there are any users there already with that name, if that name IS there, an error pops up on the screen telling the user to try a different name.
What I need help on is; how would i call from mysql just to get the username instead of using for, foreach, or while? I mean could I do something like this:
//This is where I need help//
mysql_query("SELECT user_name FROM users WHERE user_name=$user_name");
//I want to make $user_name a variable so that I can use it in the next part to see if user exists//
if(isset($input_username) && isset($input_password))//stuff user inputs into fields//
{
if($input_username == $user_name)
{
echo"<font face=\"Arial\" color=\"red\"><h2>Sorry username is already taken!</h2></font>";
}
else
{
//encrypts for database and puts in db if user does not exists//
$encrypt_pass=MD5("$input_password");
$query="INSERT INTO users (user_name, user_password) values ('$input_username', '$encrypt_pass')";
mysql_query($query, $link);
}
//Tells user new username//
echo"<font face=\"Arial\">Thank you for signing up. Your new username is $input_username</font>";
}