Im just wondering,
If someone could show me how when a user enters a username the php script checks the database to see if that username has been used before. If it has been user then let the user chose another one, and if it hasn't then continue on to the next webpage.
Please show me.
Thanks, Daniel.
Or can you point me towards a tutorial that can.
Another Problem
Moderator: General Moderators
Logic:
User submits username.
Check if that username is in the database. mysql_query() (SELECT)
If it is, show them an error prompting them to choose a different username. if(in database){ error }
If it isn't, allow them to continue the script. else { continue }
User submits username.
Check if that username is in the database. mysql_query() (SELECT)
If it is, show them an error prompting them to choose a different username. if(in database){ error }
If it isn't, allow them to continue the script. else { continue }
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
-
Darksevear
- Forum Newbie
- Posts: 11
- Joined: Sat May 13, 2006 10:38 pm
Code
Can u write me a quick example please.
- Cheers, Daniel
- Cheers, Daniel
Code: Select all
$db = mysql_connect('localhost','user','password') or die(mysql_error());
mysql_select_db('my_database',$db);
if(!empty($_POST)){
$username = mysql_real_escape_string($_POST['username']);
$result = mysql_query("SELECT count(*) FROM `users` WHERE `username` = '$username'") or die(mysql_error());
$count = mysql_result($result,0);
if($count > 0){
die('This username is already in use. Please select a different username.');
}
// continue script here
// the username does not already exist
}Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.