burnside Posted February 27, 2008 Share Posted February 27, 2008 Hey i have a VERY simple script to check if a username all ready taken : if($_GET['action'] == "personel" ) { $username = $_POST['username']; $check1 = mysql_query("SELECT username FROM members WHERE username='$username'"); if ((mysql_num_rows($check1) != 0)) { echo 'Sorry, Name already in use<br>'; } else { $updateuserdb = mysql_query("update members set username='$username' where id=$info[id]"); echo "You have changed your username. You need to relogin please.<br>"; } } it works fine, Problem is i want to add a few more details like email address etc .... all i want to know is there away if they dont change there username it wont display the name all ready taken error.? Sorry if i havent explaned this very well. Quote Link to comment Share on other sites More sharing options...
deansatch Posted February 27, 2008 Share Posted February 27, 2008 If it is for updating account or profile info, I would assume the user would be logged in already so you would have a username stored in a session. If you make an if statement like if($_GET['action'] == "personel" ) { $username = $_POST['username']; $email = $_POST['email']; if($_SESSION['username'] != $username ){ $check1 = mysql_query("SELECT username FROM members WHERE username='$username'"); if ((mysql_num_rows($check1) != 0)) { echo 'Sorry, Name already in use<br>'; } else { $updateuserdb = mysql_query("update members set username='$username' where id=$info[id]"); echo "You have changed your username. You need to relogin please.<br>"; } } elseif($_SESSION['username'] == $username ) { $updateuserdb = mysql_query("update members set email='$email' where id=$info[id]"); echo "You have changed your email."; } } Something like that anyway. Quote Link to comment Share on other sites More sharing options...
burnside Posted February 27, 2008 Author Share Posted February 27, 2008 yeah get what you mean using cookies.. Quote Link to comment 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.