[nycphp-talk] Having a form return to itself after "submit"
Mitch Pirtle
mitch.pirtle at gmail.com
Sat Oct 9 16:28:34 EDT 2004
On Sat, 9 Oct 2004 16:21:49 -0400, leam at reuel.net <leam at reuel.net> wrote:
> Ever the newbie...
>
> I have some forms that submit stuff into a database. The "entry" form calls the "insert" form, and then the "insert" form echos "Done". Inelegant, and certainly a pain to my users who will have to click "back" everytime they want to insert more than one entry.
>
> Is there a good way to have the "submit" action do the submit and then go back to the "Entry" form?
Hey Leam,
An easy way to do this is to check at the top of your script if the
form has been submitted yet - and if not, then render the form. So
for example a login form with login and password fields:
<?php
if( $_POST['login'] ){
// insert data into database and so on
} else {
// output the form here
}
?>
Of course a much better way to handle it would be to just use
HTML_QuickForm from pear.php.net, as it also has a bunch of handy
routines to validate form input, sanitize data, and so on.
Do take a look, it could save you a lot of time ;-)
-- Mitch
More information about the talk
mailing list