我制作了一个登录检查脚本,检查用户名和密码是否与数据库中设置的帐户匹配。一切正常,但它不区分大小写,它真的应该是!我该怎么做才能让这个脚本也检查大写/小写?例如:我有一个用户名:Admin 密码:My43sGG 的帐户。如果我在登录字段中输入 admin 和 my43sgg 也可以。
我的脚本:
<?php
// connect to the database
include("config.php");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM " .$members. " WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:index.php");
}
else {
?>