pudge1 Posted August 4, 2010 Share Posted August 4, 2010 So I am creating a sign up script and part of the script has a function that checks if a username exists but everytime I try it, it shows that the username is already in use when it isn't... the database is empty. function Check_Username($username) { $user = 'nintendo_note'; $pass = 'zeno118'; $dbname = 'nintendo_note'; $connection = mysql_connect('localhost',$user,$pass); mysql_select_db($dbname, $connection); $query="select Username from Users"; $result=mysql_query($query); while($row=mysql_fetch_array($result)) { if($username == $row['Username']) { return False; } else { } } } and the actual use: if(!Check_Username(md5($_POST['username']))) { echo "Sorry username is already taken. Please choose another."; include_once('right.php'); exit; } I tried changing a lot of things and moving things around but nothing seems to work. I have also gone over the code many times. The e-mail section is coded the exact same way but for some reason it always thinks the e-mail is never taken. Quote Link to comment https://forums.phpfreaks.com/topic/209746-check-username-doesnt-work/ Share on other sites More sharing options...
mac.happer Posted August 4, 2010 Share Posted August 4, 2010 sorry i havnt idea abt this Quote Link to comment https://forums.phpfreaks.com/topic/209746-check-username-doesnt-work/#findComment-1094973 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.