<html>
<body>
<form action="test.php" method="get">
UN: <input type="text" name="U">
<input type="submit">
</form>
</body>
</html>
上面的输入被发送到下面的"test.php",在那里它会和我的数据库中的当前数据进行校验。
<?php
$hostname = "test.db.some#.somehost.com";
$username = "test";
$dbname = "test";
$password = "password";
$usertable = "test";
$yourfield = "UN";
mysql_connect($hostname, $username, $password) OR DIE ("Unable to
connect to database! Please try again later.");
mysql_select_db($dbname);
$query = "SELECT * FROM $usertable WHERE $yourfield = $_GET["U"]";
$result = mysql_query($query);
if ($result) {
while($row = mysql_fetch_array($result)) {
$name = $row["$yourfield"];
echo "Hello: $name<br>";
}
}
else {
echo "User dosen't exit!";
}
mysql_close();
?>
以下是我收到的错误信息> *在第20行,/home/content/81/11107981/html/test.php中语法错误,意外的'"',期望T_STRING或T_VARIABLE或T_NUM_STRING*
我知道我已经接近成功了,但我还想要更好的结果。 ;)