Jump to content

Recommended Posts

This is a script where user can search jobs by selecting a location or category and entering a search keyword. It works fine in Mozilla but turns up nothing in IE?

Can anyone help me?

if (isset($_POST['Search'])) {

   $query  = "SELECT * FROM jobs WHERE NOW() < expires  AND paid = 'yes' ";	
   $keyword = trim($_POST['keyword']);
   
   if($_POST['keyword']!=''){
  
  $find = mysql_real_escape_string(htmlentities($_POST['keyword']));
  $find = strtoupper($find);
  $find = strip_tags($find);
  $find = trim ($find); 
  
     if(($_POST['category']!='')&&($_POST['location']!='')){

	   $query .= "AND category = '".mysql_real_escape_string($_POST['category'])."'  
    	              OR location = '".mysql_real_escape_string($_POST['location'])."' 
				  OR title LIKE '%$find%'";
				  $search = TRUE;

 	 }
   elseif(($_POST['category']!='')&&($_POST['location']=='')){

	   		   $query .= "AND category = '".mysql_real_escape_string($_POST['category'])."' OR title LIKE '%$find%'";
			   $search = TRUE;

    }
   elseif(($_POST['category']=='')&&($_POST['location']!='')){
    		
		       $query .= " AND location = '".mysql_real_escape_string($_POST['location'])."' OR title LIKE '%$find%'";
	           $search = TRUE;

}
else
{

  $query .= "AND title LIKE '%$find%'";
	           $search = TRUE;

}

}

else{
if($_POST['location']!=''){// Check if the location isnt empty
       if($_POST['category']==''){ // Check if category is empty 
       
	   $query .= "AND location = '".mysql_real_escape_string($_POST['location'])."'"; 
	   $search = TRUE;

   }// End if category is empty
   }// End if location isnt empty

       	    if($_POST['category']!=''){// Check if the category isnt empty
           if($_POST['location']==''){ // Check if location is empty 
       
	   $query .= "AND category = '".mysql_real_escape_string($_POST['category'])."'"; 
	   $search = TRUE;


   }// End if location is empty
   }// End if category isnt empty	
        
	    if($_POST['category']!=''){// Check if the category isnt empty
           if($_POST['location']!=''){ // Check if location is empty 
       
	   $query .= "AND category = '".mysql_real_escape_string($_POST['category'])."' AND location = '".mysql_real_escape_string($_POST['location'])."'"; 
	   $search = TRUE;

      }// End Else
   }// End if location isnt empty
   }// End if category isnt empty	
   
   if($search){
$aa = mysql_query($query) or die(mysql_error());
     while($row = mysql_fetch_array($aa)){
  
echo $row['title'];

 }// End While  
   }// End if Search is true
   else
   {
   
   echo 'No search term selected.';
   
   }
}// End if form was submitted   

You need to help us by telling us what works and what does not. Does the form work and submit the proper data? Does the query fail and execute your or die() statement? Does the search run but return zero results? Do you just get a blank screen? Does the form page just redisplay?

I would guess that your form either uses an image for the submit button or the form is invalid HTML. Either of these (and probably several more form problems that I did not mention) would cause different browsers to submit different data to the form processing code. Posting your form would allow someone to determine if it is where the problem is.

 

Programs only do what the code tells them. In your posted code if (isset($_POST['Search'])) won't be true if $_POST['Search'] is not set, resulting in a blank page... Work back from there to find out what the problem is.

In case someone happens upon this thread, here is how php receives the form data when an image is used for the submit button - http://www.php.net/manual/en/faq.html.php#faq.html.form-image

 

Apparently IE only sends the name_x and name_y, while other browsers send the name, name_x, and name_y variables. The solution is to look for the name_x and/or name_y, and not just the name variable.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.