Jump to content

This code is not IE compatibe (shocker I know)!


pioneerx01

Recommended Posts

I have this search page that I am working on that works as it should in Firefox, but not at all in IE. Basically if I search for letters 'lee' in any capitalization form I get all the results with anyone having the letters 'lee' in their name, (in that order). But nothing in IE. Since I am not PHP expert I do not know what is wrong. Can anyone help?

 

if(isset($_POST['submit']))
  { 
  if(isset($_GET['go'])){ 
  if(preg_match("/^[  a-zA-Z0-9-]+/", $_POST['name']))
  $name=trim($_POST['name']);{ 
  $db=mysql_connect  ("", "", "") or die ('I cannot connect to the database  because: ' . mysql_error()); 
  $mydb=mysql_select_db(""); 
 $sql="
SELECT * FROM Project_Registrations WHERE 
      first_name1  LIKE '%" . $name .  "%' 
  OR   last_name1  LIKE '%" . $name .  "%'
  OR first_name_2  LIKE '%" . $name .  "%'
  OR  last_name_2  LIKE '%" . $name .  "%'
  OR first_name_3  LIKE '%" . $name .  "%'
  OR  last_name_3  LIKE '%" . $name .  "%'
  OR  project      LIKE '%" . $name .  "%' 
  OR  teacher_name LIKE '%" . $name .  "%'
  OR  school_name  LIKE '%" . $name .  "%'
ORDER BY school_name ";

  $result=mysql_query($sql); 
  echo mysql_error();
  while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { 
      echo " --rest of the code--

 

($_GET['go']) comes from URL that is send by other page

Link to comment
Share on other sites

It is not PHP, but here it is:

 

<!DOCTYPE  HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
  <head> 
    <meta  http-equiv="Content-Type" content="text/html;  charset=iso-8859-1"> 
    <title>Search  Contacts</title> 
  </head> 
  <p><body> 
    <h3>Search  Contacts Details</h3> 
    <p>You  may search either by first or last name</p> 
    <form  method="post" action="search.php?go"  id="searchform"> 
      <input  type="text" name="name"> 
      <input  type="submit" name="submit" value="Search"> 
    
    </form> 
  </body> 
</html> 

Link to comment
Share on other sites

Since you're using both POST and GET, try printing both arrays to see if the values you expect to be there are actually there. Put the following code prior to the if(isset($_POST['submit']))

 

echo 'GET:';
echo '<pre>';
print_r($_GET);
echo '</pre>';
echo 'POST:';
echo '<pre>';
print_r($_POST);
echo '</pre>';

Link to comment
Share on other sites

Ok, the code works but I am having relative issues to IE (again)

 

So I type in 'Jim' into search box (in IE) click search I get nothing. I hit the back button and hit search again and there are the results.

What is up with the two step program? Firefox still works well.

Link to comment
Share on other sites

I recommend that you echo the $sql variable so that you can see exactly what your query is.

 

I suspect that register_globals are on and you have either a session variable or a cookie variable (that is only set in IE) with the same name as one of your post/get variables from the form.

Link to comment
Share on other sites

Ok here is the entire code (rest is a little complicated):

 

<table id="s_main_table">

<?php
"echo 'GET:';
echo '<pre>';
print_r($_GET);
echo '</pre>';
echo 'POST:';
echo '<pre>';
print_r($_POST);
echo '</pre>';"
?>
<?php
  if(isset($_POST['submit']))
  { 
  if(isset($_GET['go'])){ 
  if(preg_match("/^[  a-zA-Z0-9-]+/", $_POST['name']))
  $name=trim($_POST['name']);{ 
  $db=mysql_connect  ("", "", "") or die ('I cannot connect to the database  because: ' . mysql_error()); 
  $mydb=mysql_select_db(""); 
 $sql="
SELECT * 	FROM 
  Project_Registrations 
WHERE 
      first_name1  LIKE '%" . $name .  "%' 
  OR   last_name1  LIKE '%" . $name .  "%'
  OR first_name_2  LIKE '%" . $name .  "%'
  OR  last_name_2  LIKE '%" . $name .  "%'
  OR first_name_3  LIKE '%" . $name .  "%'
  OR  last_name_3  LIKE '%" . $name .  "%'
  OR  project      LIKE '%" . $name .  "%' 
  OR  teacher_name LIKE '%" . $name .  "%'
  OR  school_name  LIKE '%" . $name .  "%'
ORDER BY school_name ";

  $result=mysql_query($sql); 
  echo mysql_error();
  while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { 
      echo "
  
<tr><td colspan='4' ID='s_first'></td></tr>
<tr><td ID='s_fix'>School Name</td><td colspan='3' ID='s_fixb'>{$row['school_name']}</td></tr>
<tr><td ID='s_fix'>Teacher Name</td><td colspan='3' ID='s_fixb'>{$row['teacher_name']}</td></tr>
<tr><td ID='s_fix'>Project Title</td><td colspan='3' ID='s_fixb'>{$row['project_title']}</td></tr>
<tr><td ID='s_fix'>Project Number</td><td colspan='3' ID='s_fixb'>{$row['project']}</td></tr>
<tr><td ID='s_fix'>Form Submission</td><td colspan='3' ID='s_fixb'>";
if ($row['form']=="No") echo "<span ID='s_no'>NO</span> (<a href='#'>print them out now</a>)"; else echo "<span ID='s_yes'>Yes</span>"; echo"</td></tr>
<tr><td colspan='4' ID='s_mid'></td></tr>
<tr><td ID='s_fix_2'>Registered Students</td><td ID='s_fix_3'>Photo Release Form</td><td ID='s_fix_4'>Paid</td><td ID='s_side'";
if ($row['first_name_2']!="" and $row['first_name_3']!="") echo "rowspan='4'"; else echo "";
if ($row['first_name_2']!="" and $row['first_name_3']=="") echo "rowspan='3'"; else echo "";
if ($row['first_name_2']=="" and $row['first_name_3']=="") echo "rowspan='2'"; else echo "";
if ($row['paid1']=="No") echo "align='center' style='color:#FF0000'>If student does not have their payment in by our <a href='#'>deadlines</a>,<br/> they will not be able to participate in 2011 AzSEF"; else echo"";
if ($row['paid1']=="Yes" and $row['paid2']=="No" and $row['first_name_2']!="") echo "align='center' style='color:#FF0000'>If student does not have their payment in by our <a href='#'>deadlines</a>,<br/> they will not be able to participate in 2011 AzSEF"; else echo"";
if ($row['paid1']=="Yes" and $row['paid2']=="Yes" and $row['paid3']=="No" and $row['first_name_3']!="") echo "align='center' style='color:#FF0000'>If student does not have their payment in by our <a href='#'>deadlines</a>,<br/> they will not be able to participate in 2011 AzSEF"; else echo"";

echo"</td></tr>

<tr><td ID='s_fix_2b'>{$row['first_name1']} {$row['last_name1']}</td><td ID='s_fix_3b'>"; 
if ($row['pr']=="No") echo "<span ID='s_no'>NO</span> (<a href='#'>print out one now</a>)"; else echo "<span ID='s_yes'>Yes</span>";
echo"</td><td ID='s_fix_4b'>"; 
if ($row['paid1']=="No") echo "<span ID='s_no'>NO</span> (<a href='#'>pay now</a>)"; else echo "<span ID='s_yes'>Yes</span>";
echo"";

if ($row['first_name_2']=="") echo ""; else echo "<tr><td ID='s_fix_2b'>{$row['first_name_2']} {$row['last_name_2']}</td><td ID='s_fix_3b'>";
if ($row['pr2']=="Yes" and $row['first_name_2']!="") echo "<span ID='s_yes'>Yes</span>"; else echo ""; 
if ($row['pr2']=="No" and $row['first_name_2']!="") echo "<span ID='s_no'>NO</span> (<a href='#'>print out one now</a>)"; else echo "";
echo"
</td><td ID='s_fix_4b'>";
if ($row['paid2']=="Yes" and $row['first_name_2']!="") echo "<span ID='s_yes'>Yes</span>"; else echo ""; 
if ($row['paid2']=="No" and $row['first_name_2']!="") echo "<span ID='s_no'>NO</span> (<a href='#'>pay now</a>)"; else echo ""; 
echo"
</td><td></td></tr>"; echo"";

if ($row['first_name_3']=="") echo ""; else echo "<tr><td ID='s_fix_2b'>{$row['first_name_3']} {$row['last_name_3']}</td><td ID='s_fix_3b'>";
if ($row['pr3']=="Yes" and $row['first_name_3']!="") echo "<span ID='s_yes'>Yes</span>"; else echo ""; 
if ($row['pr3']=="No" and $row['first_name_3']!="") echo "<span ID='s_no'>NO</span> (<a href='#'>print out one now</a>)"; else echo "";
echo"
</td><td ID='s_fix_4b'>";
if ($row['paid3']=="Yes" and $row['first_name_3']!="") echo "<span ID='s_yes'>Yes</span>"; else echo ""; 
if ($row['paid3']=="No" and $row['first_name_3']!="") echo "<span ID='s_no'>NO</span> (<a href='#'>pay now</a>)"; else echo ""; 
echo"
</td><td></td></tr>"; 

echo"
<tr><td colspan='4' ID='s_last'></td></tr>"
;}}}}
echo "</table>"


?> 

 

And yes I do not have nothing found as results if nothing is found...

Link to comment
Share on other sites

If I had a penny for everytime I said this....

 

if(isset($_POST['submit'])) is NOT fully compatible with IE. If using IE and the user pressed the enter key to submit the form, IE will not send the submit button as a form input and thus your code won't detect the fact that the form is submitted because isset($_POST['submit']) is false.

 

Use if($_SERVER['REQUEST_METHOD'] == 'POST')

Link to comment
Share on other sites

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.