Jump to content

[SOLVED] Searching with IE


squiblo

Recommended Posts

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>


Link to comment
https://forums.phpfreaks.com/topic/168612-solved-searching-with-ie/
Share on other sites

<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>

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>

 

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"

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.