Hi guys, I am coding a simple search engin type thingy but I keep getting errors such as "Notice: Undefined variable: item in c:\program files\easyphp1-8\www\results.php on line 11" It can't find the item variable i teh forms input and for some reason the if empty input thingy doesn't work aswell.
Heres my code.
Please Help me 😃 A big thanks in advance!
//////////////////////////////////////////////////////////////////
search.html
////////////////////////////////////////////////////////////////////
<HTML>
<HEAD>
<TITLE>Order Status Page</TITLE>
</HEAD>
<BODY>
<H2>Search for your order status</H2>
<BR>
<FORM ACTION="results.php" METHOD="POST">
Please enter your eBay Item#:
<BR>
<INPUT NAME="item" TYPE="TEXT">
<BR>
<INPUT TYPE="SUBMIT" VALUE="Search">
</FORM>
</BODY>
</HTML>
/////////////////////////////////////////////////////////////
results.php
////////////////////////////////////////////////////////////
<HTML>
<HEAD>
<TITLE>Order Status Page: Search Results</TITLE>
</HEAD>
<BODY>
<H2>Search Results</H2>
<BR />
<?
$link ="<BR><BR><A HREF='search.html'>Click here to go back to the search page.</A>";
if(!isset($item) || $item==''){
echo "No search item# given.";
echo $link;
exit;
}
$item = trim($item);
$db = mysql_connect("localhost","root");
mysql_select_db("status", $db);
$query = "SELECT status.item, status.track, status.stock, status.payment FROM status WHERE item LIKE '%".$item."%'";
$result = mysql_query($query);
if (mysql_num_rows($result) == 0) {
echo "Sorry no matching item#s found.";
echo $link;
exit;
}
while ($record = mysql_fetch_assoc($result)) {
while (list($fieldname, $fieldvalue) = each ($record)) {
echo $fieldname.": <B>".$fieldvalue."</B><BR>";
}
echo "<BR>";
}
echo $link;
?>
<BR>
<A HREF="search.html">Click here to go back to the search page.</A>
</BODY>
</HTML>