Page 1 of 1

form submission - IE

Posted: Thu Apr 20, 2006 2:34 pm
by cyberpac9
i have a php form that searches our database. the formatting is done via css. i've tested the form using Firefox and everything works perfectly. when i tried the form in IE it doesn't work as planned, and i've never seen this before. when entering the search string into the search text box and the user hits enter on the keyboard, nothing happens. the user has to use the mouse to click the search button...again, this only happens in IE.

i don't know if my problem lies in some of my javascript, php, css or something else entirely. does anyone have any idea why hitting Enter does not work unless you click it with the mouse?

Posted: Thu Apr 20, 2006 2:38 pm
by feyd
Your script is looking for the submit button to determine if the page has been submitted to. IE does not send the submit button if you hit enter while inside a text box (and a few other controls.) This is why I always, always, always recommend people look for other fields or better yet, $_SERVER['REQUEST_METHOD'] for a post.

Posted: Thu Apr 20, 2006 2:39 pm
by n00b Saibot
did you put submit button as <input type="button" ...> instead of <input type="submit" ...> ?
feyd wrote:This is why I always, always, always recommend people look for other fields or better yet, $_SERVER['REQUEST_METHOD'] for a post.
is (count($_POST) > 0) good alternative ?

Posted: Thu Apr 20, 2006 2:45 pm
by feyd
There are many methods that work pretty well across the board. As long as validation is performed, I'm personally cool with most of them. count() is fine to the degree of detecting a post submission. I personally prefer the request method check myself.

Posted: Thu Apr 20, 2006 2:47 pm
by cyberpac9
@feyd: i'm not familiar with the request method, how do you go about using that - that looks like my best option...

@n00b Saibot: it is type=submit, not button...

Posted: Thu Apr 20, 2006 2:54 pm
by Ollie Saunders
well i have to say i'm confused. either i've got this very wrong or feyd and n00b Saibot have. as far as I can understand this problem is entirely client side and purely to do with your HTML/JS. Post your HTML and I'll probably be able to tell you what up.

Posted: Thu Apr 20, 2006 2:59 pm
by feyd
cyberpac9, read your private messages.

Posted: Thu Apr 20, 2006 3:05 pm
by cyberpac9
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Code: Select all

<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Online Course Search</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script language="JavaScript" type="text/javascript" src="popup.js">
</script>
<script language="JavaScript" type="text/javascript">
function doClear(theText) {
   if (theText.value == theText.defaultValue) {
      theText.value = ""
   }
}

function doCheck(theText) {
   var s = theText.value;
   while (s.substring(0,1) ==' ') {
      s=s.substring(1,s.length);
   }

   if (s == "") {
      theText.value = "Enter Last Name";
   }
}
</script>
<style type="text/css">
<!--
@import url(classes.css);
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div align="center">
  <table width="650" border="1" cellspacing="0" cellpadding="3">
    <tr>
      <td valign="top"> 
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr> 
            <td><p align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="5"><b>Online 
                Course Search</b></font><br />
                <br />
              </p>
              <table width="75%" border="0" align="center" cellpadding="3" cellspacing="0" class="header">
                <tr> 
                  <td valign="top"> <table width="100%" border="0" cellpadding="0" cellspacing="0">
                      <tr> 
                        <td valign="top"><b><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">The 
                          quick brown fox jumps over the lazy dog. The quick brown 
                          fox jumps over the lazy dog. The quick brown fox jumps 
                          over the lazy dog. The quick brown fox jumps over the 
                          lazy dog. The quick brown fox jumps over the lazy dog. 
                          The quick brown fox jumps over the lazy dog. The quick 
                          brown fox jumps over the lazy dog. The quick brown fox 
                          jumps over the lazy dog</font></b></td>
                      </tr>
                      <tr> 
                        <td valign="top"> <hr /> </td>
                      </tr>
                    </table></td>
                </tr>
              </table>
              
            </td>
          </tr>
          <tr> 
            <td>&nbsp; </td>
          </tr>
		  <tr> 
            <td><div class="search">
<form name="find" id="find" method="post" action="<? echo $_SERVER['PHP_SELF']; ?>">
<p>Search For: <strong><?
if($_POST['Submit'] == True){
	echo $_POST['lname'];
}
?></strong>
</p>
  <p>Last Name: 
    <input name="lname" type="text" id="lname" value="Enter Last Name" onfocus="doClear(this)" onblur="doCheck(this)" class="searchtext" /> 
  <input name="Submit" type="Submit" id="Submit" value="Submit" class="FormButton" />
</p>
</form>
<?
if($_POST['Submit'] == True){
	
$db_conn = @mssql_connect("","","") or die( "ERROR: Connection to database failed, please contact the webmaster at <a href=\"mailto:email\">email</a>." ); 			
			
			// select database 
mssql_select_db( "DB", $db_conn ) or die( "ERROR: Selecting database failed,<br>Please contact the webmaster at <a href=\"mailto:email\">email</a>." );

$lname = $HTTP_POST_VARS["lname"];

//You should now this but be sure to connect to your database or this is useless. :/ 
if ($lname == "") 
{$lname = '%';} 


$result = mssql_query ("SELECT dbo.tbl_class_participant.participant_fname, dbo.tbl_class_participant.participant_lname, dbo.tbl_class_participant.dept_other, dbo.tbl_list_department.department_desc, dbo.tbl_class.class_type_id FROM dbo.tbl_class_participant INNER JOIN dbo.tbl_class_listing ON dbo.tbl_class_participant.participant_id = dbo.tbl_class_listing.participant_id INNER JOIN dbo.tbl_class ON dbo.tbl_class_listing.class_id = dbo.tbl_class.class_id INNER JOIN dbo.tbl_list_department ON dbo.tbl_class_participant.department_id = dbo.tbl_list_department.department_id WHERE (dbo.tbl_class_participant.participant_lname LIKE '$lname%') ORDER BY dbo.tbl_class_participant.participant_lname, dbo.tbl_class_participant.participant_fname");


if ($row = mssql_fetch_array($result)) { 
do {
	echo "<table width = \"625\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr bgcolor=\"#E0E0E0\"><td width=\"150\"><strong>Name</strong></td><td width=\"200\"><strong>Department</strong></td><td width=\"150\"><strong>Other</strong></td><td width=\"125\"><strong>Class</strong></td></tr>";
	echo "<tr><td>";
	echo $row["participant_fname"];
	echo " ";
	echo $row["participant_lname"];
	echo "</td><td>";
	echo ucwords(strtolower($row["department_desc"]));
	echo "</td><td>";
	echo $row["dept_other"];
	echo "</td><td>";
	echo $row["class_type_id"];
	echo "</td></tr></table><br />";
} while($row = mssql_fetch_array($result)); 
} else {print "Sorry, no records were found!";} 	
}
?>
			</div></td>
          </tr>
		  <tr> 
            <td>&nbsp; </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</div>
</body>
</html>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Apr 20, 2006 3:12 pm
by Ollie Saunders
Change

Code: Select all

<input name="Submit" type="Submit" id="Submit" value="Submit" class="FormButton" />
to

Code: Select all

<input name="anything not equal to submit" type="Submit" id="anything not equal to submit" value="anything not equal to submit" class="FormButton" />

Posted: Thu Apr 20, 2006 3:15 pm
by cyberpac9
^^ didn't work...

Posted: Thu Apr 20, 2006 3:15 pm
by Christopher
I'd recommend adding a hidden <input> to the form and checking for it rather than the submit <input>. I just demonstrated a login form that does this here.

Posted: Thu Apr 20, 2006 3:22 pm
by cyberpac9
@arborint: that worked! thanks a bunch...left my code alone and just added a hidden field and checked that...