今天我做了一个应该登录的代码,但遗憾的是它不会。
这是我尝试过的:
include('php/mysqlcon.php');
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$username = $_POST['username'];
$password = sha1($_POST['password']);
$query = mysql_query("SELECT * FROM user WHERE username=$username AND password=$password");
$query_rows = mysql_num_rows($query);
if($query_rows > 0) {
session_start();
$_SESSION['username'] = $username;
header('Location: index.php');
} else {
echo('bad login');
}
}
mysql 的详细信息在 mysqlcon.php 中,我确定它们是正确的