[UPHPU] Posting a form
Scott.Hill at flyingj.com
Scott.Hill at flyingj.com
Thu Feb 24 09:21:38 MST 2005
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
More information about the UPHPU
mailing list