SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
-
Feb 26, 2006, 08:13 #1
Problems with uppercase and lowercase.....
Hi,
Im having problems with comparing data that has a capital letter at the front.
In my MySQL database there is a username Admin, and when someone trys to make a new user with the name of admin it will let them and the check will fail, so there will be two people with the same usernames.....
Is there a simple way to make this code pick up that the usernames are the same?
PHP Code:$sql = "SELECT name FROM schools WHERE name = '".$_POST['schoolname']."' LIMIT 1";
$res = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($res) > 0) {
$name_check = mysql_result($res, 0, 0);
}else{
//Not found
}
if ($name_check == $_POST['schoolname']) {
$_SESSION['error'] = "takenname";
die(header ("location: main.php?page=error"));
}
Thanks,
Rainingwww.thetrial.staronesw.com
Check out my online text based rpg (In development!!)
-
Feb 26, 2006, 08:19 #2
- Join Date
- Aug 2004
- Location
- Manchester UK
- Posts
- 13,807
- Mentioned
- 158 Post(s)
- Tagged
- 3 Thread(s)
Afternoon Raining,
PHP Code:$var_lc = strtolower($_POST['schoolname']);
$var_orig = $_POST['schoolname'];
$sql = "SELECT name FROM schools WHERE name = '".$var_lc."' or name = '". $var_orig ."' LIMIT 1";
$res = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($res) > 0) {
$name_check = mysql_result($res, 0, 0);
}else{
//Not found
}
if ($name_check == $_POST['schoolname']) {
$_SESSION['error'] = "takenname";
die(header ("location: main.php?page=error"));
}
SpikeMike Swiffin - Community Team Advisor
Only a woman can read between the lines of a one word answer.....
-
Feb 26, 2006, 08:23 #3
Long time no see Spike
, thanks for the help.
That is how I thought I could do it, but I wasent sure if there was a more simple way. The only problem I will have now, is that I could end up with someone called Admins, and someone else called aDmins lol.
Thanks,
Rainingwww.thetrial.staronesw.com
Check out my online text based rpg (In development!!)
-
Feb 26, 2006, 10:20 #4
- Join Date
- Aug 2004
- Location
- Manchester UK
- Posts
- 13,807
- Mentioned
- 158 Post(s)
- Tagged
- 3 Thread(s)
The way around that is to stop the casing when the user signs up or use a LiKE in the query.
PHP Code:$sql = "SELECT name FROM schools WHERE name LIKE '".$var_lc."' or name LIKE '". $var_orig ."' LIMIT 1";
$res = mysql_query($sql) or die(mysql_error());
MikeMike Swiffin - Community Team Advisor
Only a woman can read between the lines of a one word answer.....
Bookmarks