[UPHPU] Posting a form

D. Turnbull turnbull at xmission.com
Thu Feb 24 09:33:44 MST 2005


An alternate approach would be to include a hidden form field, and test 
for that instead of the submit value -- assuming all other form values 
are being sent. Beyond that, you're probably looking at a javascript 
solution tying an Enter key event to the submit button, but I'm not sure 
I'd want to travel that path.

Dave

Scott.Hill at flyingj.com wrote:
> I have a question about posting a form using php.  I am working on an
> application that uses PHP and MySQL.  To insert or update a record I use
> the same php script for showing and processing the form.
> 
> I use the $_SERVER['PHP_SELF'] variable in the action attribute in the form
> and name the submit button. Example:
> 
> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
> 
> ...form fields
> 
> <input type="submit" name="submit" />
> </form>
> 
> I then test for $_POST['submit'] at the top of the PHP script and use the
> $_POST variables to insert into or update the database record.   Example:
> 
> if (isset($_POST['submit'])) {
>       ... process form data
> }
> 
> All of this works great!  However, the first time a real user tried it,
> they entered the data into the form and hit the enter key instead of
> clicking on the submit button.  This seems to have the same affect as
> refreshing the page.  Since the submit button was not clicked the
> $_POST['submit'] variable is not available.
> 
> Finally the question:  How do I make the enter key behave the same as
> clicking the submit button?
> All of my users insist they be able to press the enter key instead of
> clicking on the submit button or tabbing to it and then pressing enter.  I
> am at a loss.  I am open to just about anything.
> 
> Thank you,
> 
> Scott Hill
> 
> 
> _______________________________________________
> 
> UPHPU mailing list
> UPHPU at uphpu.org
> http://uphpu.org/mailman/listinfo/uphpu
> IRC: #uphpu on irc.freenode.net
> 



More information about the UPHPU mailing list