我有一个登录页面(本地 Intranet,所以不用担心安全问题)。此页面包含以下表单代码:
<form action="auth.php" method="get" class="blocklogin">
<tr>
<td class="blocklogin" ><div align="left">Username: <input class="blocklogin" type="text" name="username" id="username" /><br />
</div></td>
</tr>
<tr>
<td class="blocklogin" ><div align="left">Password: <input class="blocklogin" type="password" name="password" id="password" />
</div></td>
</tr>
<tr>
<td colspan="2" class="blockloginfoot" title="Login"><input name="Login" type="submit" value="Login" /></td>
</form>
现在我尝试通过执行以下操作通过 http 链接传递用户名和密码:
http://localhost/folder/user_login.php?username=user@test&password=test123
但这似乎不起作用,它假设使用链接中的详细信息登录。我错过了什么吗?请帮忙
表单动作 auth.php
<?php
session_start();
require_once('database.php');
$username = $_GET['username'];
$password = $_GET['password'];
$sql = "SELECT * FROM access_getaccountswithinfo WHERE username='".$username."' AND password='".$password."'";
$run = mysql_query($sql);
$row = mysql_fetch_array($run);
if (mysql_num_rows($run) == 1) {
$_SESSION['logged_in'] = true;
$_SESSION['username'] = $row['username'];
$_SESSION['password'] = $row['password'];
$_SESSION['packagename'] = $row['packagename'];
$_SESSION['creation-date'] = $row['creation-date'];
$_SESSION['cap'] = $row['cap'];
$_SESSION['total'] = $row['total'];
$_SESSION['remainingtopup'] = $row['remainingtopup'];
header("location: usage.php");
} else {
header("location: user_login.php");
}
mysql_close($link);
?>
数据库代码 - database.php :
<?php
$link = mysql_connect('localhost', 'dbase', 'pass123');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
// make dbase the current db
$db_selected = mysql_select_db('dbase', $link);
if (!$db_selected) {
die ('Can\'t use foo : ' . mysql_error());
}
?>