contra10 Posted August 3, 2009 Share Posted August 3, 2009 I'm trying to create a search bar thats when a person enters a variable it redirects them to the results page, when a person searches the first time its of but then when on the results page and a person searches then the result is an iframe with the information inside of it, and no redirect in browser. my coding <?php $find = $_POST['input']; // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); if(isset($_POST['submit'])){ header("Location: http://www.test.com/add/search.php?pagenum=1&search=$find"); } ?> <form name="search" method="post" action="<?=$PHP_SELF?>"> Seach for: <input type="text" name="input" /> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="submit" value="Search" /> </form> and the results page TEST Results <iframe src="http://www.test.ca/add/searchfor.php" scrolling="no" frameborder="0"> </iframe> <table border="0" width="900" valign="top"> <tr><td><h3>SEARCH RESULTS</h3></td></tr> </table> <table border="0" width="900" valign="top" height="500"> <?php // Connects to your Database mysql_connect("localhost", "", "") or die(mysql_error()); mysql_select_db("deals") or die(mysql_error()); //This checks to see if there is a page number. If not, it will set it to page 1 $pagenum = $_GET['pagenum']; if ($pagenum) { } else{ $pagenum = 1; } $sr = $_GET['search']; if($sr){ //Here we count the number of results $querye = "SELECT * FROM `deal` WHERE `title` LIKE '%$sr%' and `release`='yes'"; $result = mysql_query($querye) or die(mysql_error()); $rows= mysql_num_rows($result); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.