Note that there are some explanatory texts on larger screens.

plurals
  1. POOutputting searched data to another form
    primarykey
    data
    text
    <p>I'm currently building a system which gets a unique value and uses that as a login i.e a reference number. The reference number then searches the database and outputs all corresponding data to another page, I am struggling with this, my code is:</p> <p>Index.PHP </p> <pre><code>&lt;input name="search_box" type="text" class="auto-style1" id="search_box" style="width: 240px; height: 30px" maxlength="12"&gt; &lt;input type="submit" name="search" value="Enter" class="auto-style1" style="width: 63px; height: 30px"&gt;&lt;/td&gt; &lt;?php $reasons = array("search_box" =&gt; "Please Enter Valid Reference Number", "" =&gt; "Error"); if ($_GET["loginFailed"]) echo $reasons[$_GET["reason"]]; ?&gt; &lt;/form&gt; </code></pre> <p>Check.php</p> <pre><code> &lt;?php include "conn.php"; mysql_connect("localhost","root") or die(header("location:index.php?loginFailed=true&amp;reason=search_box")); mysql_select_db("DB1") or die(header("location:index.php?loginFailed=true&amp;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&amp;reason=search_box")); } ?&gt; </code></pre> <p>Output.php</p> <pre><code> &lt;?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)) { ?&gt; &amp;nbsp;&lt;font size="4" face="Calibri"&gt;&lt;b&gt; Ref Number: &lt;/b&gt; &lt;/font&gt;&lt;?php echo $row['No']; ?&gt;&lt;/td&gt; &lt;p&gt; &amp;nbsp;&lt;font size="4" face="Calibri"&gt;&lt;b&gt; Location: &lt;/b&gt;&lt;/font&gt;&lt;?php echo $row['Country']; ?&gt;&lt;/td&gt; &lt;p&gt; &lt;?php mysql_close($con); ?&gt; </code></pre> <p>Any help you guys could give would be highly appreciated, Thanks.</p> <p>Qwerty.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload