please some one help me,i have created this code for searching from database but the problem is i am getting an output without even searching,i am no php expert,so please guys help me.
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" onSubmit="return validateThis(this)"> <!-- Sending Search Keyword to "search_handler.php" -->
<p>
<label for="name" id="lname">Search Here:</label>
<input type="text" class="text" name="tag" id="tag" onfocus="input_focus('tag');" onblur="input_blur('tag');" size="50" />
</p>
<input type="submit" class="submit" name="send_contact" value="Send" />
</form>
<?php
$tag = @$_POST['tag'];
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("root", $con);
$result =mysql_query("Select * FROM `superbnexus`.`products` WHERE `prname`LIKE '%".$tag."%'");
//echo $tag;
if($row = mysql_fetch_array($result))
{
echo "<b>Name: </b>".$row[0]."<br>";
echo "<b>Product Details: </b>".$row[3]."<br>";
echo "<b>Product Price: </b>".$row[4]."<br>";
echo "<em>To Buy this Product you have to Register. To Register go to <i>Customer Menu > Product List</i></em>";
}
else
{
echo "<strong>The Product you are Searching is Not Available right now!</strong>";
}
mysql_close($con);
?>