Help - Search - Members - Calendar
Full Version: simple question
Pixel2Life Forum > Help Section > PHP, ASP, MySQL, JavaScript and other Web/Database Programming Help
derek.sullivan
I tend to use the isset function for checking my forms yada yada yada. I know allot of people just type their username and password in and then hit their keyboard [enter] key rather than pressing the [submit] button on the web page.

here is an example of the code i normally use:

CODE
<?php

if (isset($_POST['submit'])) { // $_POST['submit'] = the submit BUTTON

// begin processing the login information.

}else{

//begin form

}

?>


Now, because people like me normally DON'T use the button lol, I was wondering what another good method would be to do all this. You know what I mean?
rc69
If the button is a submit button, pressing enter implies a click on the submit button. So you don't have to worry about it.
derek.sullivan
ahh okay, well sometimes when I type in a text field or something, I can hit enter but nothing appears because i didn't specifically click the [Submit] button. so if I don't have to worry than all is well.
rc69
Slight correction to what i said before. It turns out a bug exists in IE8 that makes your question something worth worrying about:
IE anomaly when using the enter key to submit a form

Synopsis:
Form with one text field and a submit button.
Type some text, press enter, the submit button doesn't get included in the post to the server.

Fix:
Add another text field (not a hidden field).
NDBoost
why not use a hidden field with a rand var for checkign to make sure that the form was submitted using normal methods? Its what i do.

something along the lines of
CODE
<input type="hidden" name="key" id="key" value="<?= $rand ?>" />

Set the $rand that was generated to a session, and then compare the key value to the session value to make sure it matches..
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.