Jump to content

[solved] Prevent problems with logging


lambik

Recommended Posts

Hi. This time I have another problem with logging on on my website. I created username lambik and registered. When I try registering new username as LaMBik, it doesnt count, but if I try log on as LaMBik it is accepted and it is causing a lot of problems. For example I cant send message to myself but when I am logged as LaMBik I can and then it causes a lot of bugs...In login form I tried this code

$sql="SELECT * from users WHERE meno=='$_POST[login]' && heslo=='$_POST[heslo]'";$result=mysql_query($sql,$spojenie) or die(mysql_error());return  mysql_num_rows($result);

If the last line is equal to 1 it will log me on. But there is an error which says You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=='' && heslo==''' at line 1 and that means I must change that code to this

$sql="SELECT * from users WHERE meno='$_POST[login]' && heslo='$_POST[heslo]'";$result=mysql_query($sql,$spojenie) or die(mysql_error());return  mysql_num_rows($result);

And if I have that code it allows me to log on using both nicks or I can combine big and small letters it doesnt matter. Anyone know how to solve this? Thanks

Link to comment
Share on other sites

Your query should be this:

$sql="SELECT * from users WHERE meno='{$_POST['login']}' && heslo='{$_POST['heslo']}'";

The = is the correct operator to use for SQL. The reason it is case-insensitive is because your table is using case-insensitive collation. You may see the collation on the table listed as "utf8_unicode_ci", the "ci" there means case-insensitive. If you want case-sensitive comparison you need to use a different collation for the table.

Link to comment
Share on other sites

you have to make your column collation to case sensitive collation

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...