Jump to content


simple question


4 replies to this topic

#1 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 341 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 18 June 2009 - 12:03 PM

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:

<?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?

#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 18 June 2009 - 06:18 PM

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.

#3 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 341 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 18 June 2009 - 09:48 PM

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.

#4 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 13 July 2009 - 07:21 PM

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).

Edited by rc69, 13 July 2009 - 07:23 PM.


#5 NDBoost

    Young Padawan

  • Members
  • Pip
  • 27 posts
  • Gender:Male
  • Location:Tempe, AZ

Posted 11 September 2009 - 02:50 PM

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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users