我试图弄清楚如何使我的 search.php 脚本与 mySQL 一起工作。我无法显示信息。不确定问题出在哪里。
第 1 页:
<form action="search_result.php" method="GET">
<input type="text" name="reg" />
<input type="submit" value="Search" />
</form>
第2页:
<?php
$host="localhost";
$username="XXXXXXXXXXX";
$password="XXXXXXXXXXX";
$db_name="XXXXXXXXXXXX";
$tbl_name="reg_add";
mysql_connect("$host", "$username", "$password") or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$record = $_POST['record']; // if coming from e.g. a form
$result=mysql_query(" SELECT * FROM reg_add WHERE reg='" . mysql_real_escape_string($record) . "'");
$row = mysql_fetch_assoc($result);
$first_name = $row['first_name'];
$last_name = $row['last_name'];
$reg = $row['reg'];
?>
<input name="reg" value="<? echo "$record" ?>">
<input name="first_name" value="<? echo "$first_name" ?>">
<input name="last_name" value="<? echo "$last_name" ?>">