Jump to content

[SOLVED] Submit button requires that I click it twice...


Paul_Bunyan

Recommended Posts

Hi al.  I'm encountering a weird error where my form doesn't get submitted unless I click it 2 times.  I don't mean double click, but only after I have submitted it twice.  I just wanted to see if someone could take a look at my code to see if there is something obvious that I am overlooking.  Thanks for any insight. :)  **EDIT:  I don't know where those boxes came from.  I can't see how to remove em...

 

<?php
// connection statement
require_once('../Connections/pubs_db.php');

// additional functions
require_once('../includes/functions.inc.php');
require_once('../php/functions.php');

// build the form action
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'] . (isset($HTTP_SERVER_VARS['QUERY_STRING']) ? "?" . $HTTP_SERVER_VARS['QUERY_STRING'] : "");

if (isset($HTTP_POST_VARS["Submit"])) 
{
if($HTTP_POST_VARS['contact_email'] != "")
{
	$traceMsg = "email is not blank";

   		// check if the user id and password combination exist in database
   		$sql = "SELECT username, password 
           		FROM user_directory
           		WHERE contact_email=".squote_string(parse_string($HTTP_POST_VARS['contact_email']));
	   		
	$result = $pubs_db->Execute($sql) or die('Query failed. ' .$pubs_db->ErrorMsg().$sql);

   		$commit = $pubs_db->Execute("commit") or die($pubs_db->ErrorMsg());
   
   		$totalRows = $result->RecordCount();
  
   		if ($totalRows == 1) 
   		{

  		//set subject
  		$subject = "Geotech Account Information";

		//set recipient
		$recip = $HTTP_POST_VARS['contact_email'];

      		//email username and password
		$headers = "From: [email protected]";
		$body = "This is your account information for your Geotech skills account:\n Username: ".$result->Fields('username')."\n Password: ".$result->Fields('password')."\n\ Josh Morsel Buns";

		# The format of the mail() function:
		#mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]])
		if(mail($recip, $subject, $body, $headers ) == false)
		{
			$errorMessage = 'Email failed';
		}
		else
		{
			// after login we move to the index page
  			$insertGoTo = "index.php";

			KT_redir($insertGoTo);
		}
      
   		} 
   		else 
   		{
      		$errorMessage = 'Email not on file.';
   		}

}
else 
   	{
      		$errorMessage = 'You must enter your email.';
   	}
}

?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="../mainstyl.css" rel="stylesheet" type="text/css" />
<link href="../mainstyl.css" rel="stylesheet" type="text/css" />

</div>
</head>
<style type="text/css">
<!--
.style4 {font-size: 24px}
-->
</style>
</head>

<body>
<p align="center" class="xsmallnavybold"><br />
  <br />
  <span class="navybold style4">Username/Password retrieval :</span></p>
  <p align="center" class="maroonitalicbold">Directions: Please enter the contact email that you have for this Geotech skills account. Your username and password will be emailed to you.</p>
  </div>
<?php
if ($errorMessage != '') 
{
echo $errorMessage;
}
?>
</p>
    <form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data">
  <table width="400" border="1" align="center" cellpadding="2" cellspacing="2" class="tbl_greenbordersolid">
<tr>
<td width="150" class="largebold">Contact Email:</td>
<td><input name="contact_email" type="text" id="contact_email" value="<?php echo $HTTP_POST_VARS['contact_email']; ?>" /></td>
</tr>

<tr>
<td width="150"> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>

</body>
</html>

This is most likely caused by the fact that IE will not send a value for an input type=submit if ENTER is pressed instead of clicking it. Test the form with pressing ENTER and clicking and see if there is a difference in the way the code responds.

I'm VERY curious as to why you're using $HTTP_POST_VARS instead of the better superglobal, $_POST. >_>

 

I'm pretty new to PHP and I took over a project for someone.  I modelled all my pages after his and it was just how he did things.  I'll look into using $_POST instead.  Thanks for the heads up.

 

This is most likely caused by the fact that IE will not send a value for an input type=submit if ENTER is pressed instead of clicking it. Test the form with pressing ENTER and clicking and see if there is a difference in the way the code responds.

 

Ah ok, thank you.

 

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.