我正在为班级创建一个基本网站,在我的登录 html 页面上,我有 2 个文本框用户名和密码以及一个登录按钮。在提交时,我调用 php 文件。它读取 txt_Username 但不读取 txt_Password。您是否必须以不同的方式阅读密码文本框?
提前致谢。
HTML页面代码;
</div>
<div id="Content">
<form id="loginForm" name="loginForm" method="GET" action="Login.php">
<table width="27%" border="0" align="center">
<tr>
<td width="42%">Username:</td>
<td width="58%"><input type="text" name="txt_Username" id="txt_Username" /></td>
</tr>
<tr>
<td width="42%">Password:</td>
<td width="58%"><input type="password" name="txt_Password" id="txt_Password" /> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="btn_validate" id="btn_validate" value="Login" /></td>
</tr>
<tr>
</table>
<p> </p>
</form>
</div>
PHP代码;
<?php
session_start();
$server = "host.com";
$schema = "Seatter";
$uid = "user";
$pwd = "password";
$password =$_GET["txt_Password"];
$username =$_GET["txt_Username"];
mysql_connect($server , $uid , $pwd) or die ("server not found");
mysql_select_db($schema) or die ("Database not found");
$sql = "SELECT *
FROM Login_Details
WHERE User_ID = '$username' AND Password = '$password'";
$record = mysql_query($sql) ;
if(mysql_num_rows($record) == 0){
echo "Login Failure: ";
//echo $username; //Username read from html page
echo $password; //Password not read.
//header("location: Login.html");
}
mysql_close();
?>