squiblo Posted August 3, 2009 Share Posted August 3, 2009 I dont know the best way to describe my problem but ill give it ago, ok...i have a search engine and it works fine with all browsers apart from Interent Explorer, with IE the search only works when I click enter with my mouse but does not work when I press enter on the keyboard, this has confused me for days now, here is my search script, can anyone solve this for me please. <font face="arial"> <?php //get data $button = $_GET['submit']; $search = $_GET['search']; if (!$button) header("location:advsearch.php"); else { if (strlen($search)<3) header("location:advsearch.php"); else { echo ""; //connect to our database mysql_connect("localhost","***","***"); mysql_select_db("***"); //explode our search term $search_exploded = explode(" ",$search); foreach($search_exploded as $search_each) { //construct query $x++; if ($x==1) $construct .= "username LIKE '%$search_each%'"; else $construct .= " OR username LIKE '%$search_each%'"; } //echo out construct $construct = "SELECT * FROM members WHERE $construct"; $run = mysql_query($construct); $foundnum = mysql_num_rows($run); if ($foundnum==0) echo "You searched for <b>$search</b>. No results found."; else { echo "You searched for <b>$search</b><br>$foundnum result(s) found!<p><hr size='1' width='387'color='#E6E6E6'>"; while ($runrows = mysql_fetch_assoc($run)) { //get data $state = ucwords($runrows['state']); $url = $runrows['url']; $username = ucwords($runrows['username']); $imagelocation = $runrows['imagelocation']; if ($imagelocation == "") { $imagelocation = "./profileimages/noprofilepic.jpg"; } echo " <img src ='$imagelocation' width='100' height='105' border='0' align='left' style='padding-right:10px'><br> <b>$username</b><br> $state<br> <a href='$url'>View Profile</a><br><br><br> <hr size='1' width='387' align='left' color='#E6E6E6'> "; } } } } ?> </font> Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/ Share on other sites More sharing options...
squiblo Posted August 3, 2009 Author Share Posted August 3, 2009 what can i do? Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889418 Share on other sites More sharing options...
squiblo Posted August 3, 2009 Author Share Posted August 3, 2009 if you dont understand my problem, please say and ill try to explain more Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889434 Share on other sites More sharing options...
squiblo Posted August 3, 2009 Author Share Posted August 3, 2009 :facewall: :facewall: :facewall: Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889461 Share on other sites More sharing options...
phpSensei Posted August 3, 2009 Share Posted August 3, 2009 Sorry for the delay, alot of threads that need help. Post your form please Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889464 Share on other sites More sharing options...
squiblo Posted August 3, 2009 Author Share Posted August 3, 2009 <div id="searchengine" style="position:absolute;top:160px;left:312px;z-index:15"> <form action='/results.php' method='GET'> <font face='sans-serif' size='6'> <input type='text' size='15' name='search'><input type='submit' name='submit' value='Search'> </font> </form> </div> Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889467 Share on other sites More sharing options...
phpSensei Posted August 3, 2009 Share Posted August 3, 2009 IF THE ABOVE ^^^ DOESNT WORK TRY Add this javascript to the top of your page <SCRIPT TYPE="text/javascript"> <!-- function submitenter(myfield,e) { var keycode; if (window.event) keycode = window.event.keyCode; else if (e) keycode = e.which; else return true; if (keycode == 13) { myfield.form.submit(); return false; } else return true; } //--> </SCRIPT> and change the form to <div id="searchengine" style="position:absolute;top:160px;left:312px;z-index:15"> <form action='/results.php' method='GET'> <font face='sans-serif' size='6'> <input type='text' size='15' onKeyPress="return submitenter(this,event) name='search'><input type='submit' name='submit' value='Search'> </font> </form> </div> Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889470 Share on other sites More sharing options...
squiblo Posted August 3, 2009 Author Share Posted August 3, 2009 still only works when i click the "search" button. It does not show any results when i just press enter. Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889471 Share on other sites More sharing options...
squiblo Posted August 3, 2009 Author Share Posted August 3, 2009 i put the javascript after session_start(); and before doctype is that right? Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889473 Share on other sites More sharing options...
phpSensei Posted August 3, 2009 Share Posted August 3, 2009 i put the javascript after session_start(); and before doctype is that right? in the <head></head> section Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889475 Share on other sites More sharing options...
squiblo Posted August 3, 2009 Author Share Posted August 3, 2009 when i press enter it just goes to the results.php and no results are shown Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889477 Share on other sites More sharing options...
phpSensei Posted August 3, 2009 Share Posted August 3, 2009 method='GET'> that should be method='POST'> Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889487 Share on other sites More sharing options...
phpSensei Posted August 3, 2009 Share Posted August 3, 2009 edit: nvm this Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889489 Share on other sites More sharing options...
squiblo Posted August 3, 2009 Author Share Posted August 3, 2009 search for "admin" if you view the link, this may help http://www.squiblo.com/results.php? Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889490 Share on other sites More sharing options...
squiblo Posted August 3, 2009 Author Share Posted August 3, 2009 if i search "hello" and press enter on the keyboard the url changes to "http://www.squiblo.com/results.php?search=hello" but if i search "hello" and click enter with my mouse the url changes to "http://www.squiblo.com/results.php?search=hello&submit=Search" Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889494 Share on other sites More sharing options...
phpSensei Posted August 3, 2009 Share Posted August 3, 2009 try <div id="searchengine" style="position:absolute;top:200px;left:512px;z-index:15"> <form action='http://www.squiblo.com/results.php?submit=Search' method='GET'> <font face='sans-serif' size='6'> <input type='text' size='15' name='search'><input type='submit' name='submit' value='Search'> <input type="hidden" name="submit" value="Search"> </font> </form> </div> Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889498 Share on other sites More sharing options...
squiblo Posted August 3, 2009 Author Share Posted August 3, 2009 unfortunatly nothing has changed Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889502 Share on other sites More sharing options...
phpSensei Posted August 3, 2009 Share Posted August 3, 2009 unfortunatly nothing has changed works perfect on my part... it should be working. Paste that script and try it.. Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889505 Share on other sites More sharing options...
squiblo Posted August 3, 2009 Author Share Posted August 3, 2009 so it must be my browser? would deleting all cookies etc help at all Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889509 Share on other sites More sharing options...
phpSensei Posted August 3, 2009 Share Posted August 3, 2009 so it must be my browser? would deleting all cookies etc help at all You didnt change the HTML. i can see the source, nothing has changed in it! Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889512 Share on other sites More sharing options...
Andy-H Posted August 3, 2009 Share Posted August 3, 2009 $search = $_GET['search']; if ( isset($_GET['search']) && !isset($_GET['submit']) ) { $button = True; } else { $button = isset($_GET['submit']) ? $_GET['submit'] : ''; } Try that? Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889515 Share on other sites More sharing options...
squiblo Posted August 3, 2009 Author Share Posted August 3, 2009 damn, i changed it on the wrong page, that has worked perfect now thank you Quote Link to comment https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/#findComment-889516 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.