私は現在、一意の値を取得し、それをログイン、つまり参照番号として使用するシステムを構築しています。次に、参照番号はデータベースを検索し、対応するすべてのデータを別のページに出力します。これに苦労しています。私のコードは次のとおりです。
Index.PHP
<input name="search_box" type="text" class="auto-style1" id="search_box" style="width: 240px; height: 30px" maxlength="12">
<input type="submit" name="search" value="Enter" class="auto-style1" style="width: 63px; height: 30px"></td>
<?php $reasons = array("search_box" => "Please Enter Valid Reference Number", "" => "Error"); if ($_GET["loginFailed"]) echo $reasons[$_GET["reason"]]; ?>
</form>
Check.php
<?php
include "conn.php";
mysql_connect("localhost","root") or die(header("location:index.php?loginFailed=true&reason=search_box"));
mysql_select_db("DB1") or die(header("location:index.php?loginFailed=true&reason=search_box"));
$reference1 = $_POST['search_box'];
$sql = "SELECT * FROM test_table1 WHERE No =$R1";
$result = mysql_query($sql) or die(mysql_error());
if ($result)
$count = mysql_num_rows($result);
else
$count = 0;
if($count == 1)
{
session_register('search_box');
header("location:result.php");
}
else
{
echo (header("location:index.php?loginFailed=true&reason=search_box"));
}
?>
Output.php
<?php
include "conn.php";
$sq2 = "SELECT * FROM test_table1";
if (isset($_POST['search']))
{
$search_term = mysql_real_escape_string($_POST['search_box']);
$sq2 .= "WHERE No = '{$search_term}'";
}
$query= mysql_query($sq2, $con);
while($row = mysql_fetch_array($query)) { ?>
<font size="4" face="Calibri"><b> Ref Number: </b> </font><?php echo $row['No']; ?></td>
<p>
<font size="4" face="Calibri"><b> Location: </b></font><?php echo $row['Country']; ?></td>
<p>
<?php
mysql_close($con);
?>
皆さんができるどんな助けでも大歓迎です、ありがとう。
Qwerty配列。