On Tue, 2006-08-15 at 01:24 -0400, Robert Cummings wrote:
> On Tue, 2006-08-15 at 13:02 +0800, Bigmark wrote:
> > Does anyone have a simple example script.
> >
>
> In the first form include a hidden field that identifies the form when
> you are checking the post values after submission. This way you know
> exactly what form was submitted. Second if the first form has been
> submitted then you know that you need to present the second form also.
> THe second form should also have a hidden field so that it may be
> identified upon submission. In this way you can detect which form was
> submitted (submit buttons are problematic for determining which form was
> submitted). Then when you detect that the second form was submitted you
> can handle it's data as you please and then only present the first form.
>
> A basic example follows (completely unchecked for typos/errors):
And of course it had errors :) See below...
>
> <?php
>
> $submittedForm = null;
> if( isset( $_POST['formSubmitted'] ) )
> {
> $submittedForm = $_POST['formSubmitted'];
>
> if( $_POST['formSubmitted'] == 'form1' )
> {
> // do something with its data.
> }
> else
> if( $_POST['formSubmitted'] == 'form2' )
> {
> // do something with its data.
> }
> }
> ?>
>
> <form name="form1" method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
> <input type="hidden" value="form1" />
Should be:
<input type="hidden" name="formSubmitted" value="form1" />
> <select name="game">
> <option value="1">1</option>
> <option value="2">2</option>
> <option value="3">3</option>
> <option value="...">...</option>
> </select>
> <input type="submit" name="continue" value="Continue" />
> </form>
>
> <?php
> if( $submittedForm == 'form1' )
> {
> ?>
>
> <form name="form2" method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
> <input type="hidden" value="form2" />
Should be:
<input type="hidden" name="formSubmitted" value="form2" />
> <select name="blah">
> <option value="foo">Foo</option>
> <option value="fee">Fee</option>
> <option value="fii">Fii</option>
> <option value="foh">Foh</option>
> <option value="fum">Fum</option>
> </select>
> <input type="submit" name="continue" value="Continue" />
> </form>
>
> <?php
> }
> ?>
>
> Cheers,
> Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php