我一直在使用和写的一样 . 但每当我点击它时,都会出错
注意:未定义的索引:第3行的D:\ xamp \ htdocs \ xampp \ new \ login.php中的用户名注意:第4行的D:\ xamp \ htdocs \ xampp \ new \ login.php中的未定义索引:密码输入用户名和密码
我的HTML是:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="login.php" method="POST">Username:
<input type ='text' name="username" />
password<input type="password" name="password" />
<input type="submit" value="login" /></form>
</body>
</html>
虽然我的PHP是:
<?php
$username = '$_POST[username]';
$password = '$_POST[password]';
if($username && $password)
{
$connect = mysql_connect(“localhost”, “root”, “”);
$query=mysql_query("SELECT * FROM usres WHERE username=$username");
$numrows = mysql_num_rows($query);
if (!connect) {
die('Connection Failed: ' . mysql_error());
}
mysql_select_db(“phplogin”, $connect);
}else{
die("please enter username and password");
enter code here
}
?>
1 回答
试试这个吧