|
Posted by James Taylor on 10/08/89 11:08
Nsk wrote:
> Hi
>
> I want to create a single php file which will be able to display multiple html
> forms.
>
> Like this: Form1 -> Form2 -> Form3.
>
> After the user completes and submits Form1, the script will process it and
> display a different form. etc...
>
> I am new to php, I would need some detailed instructions, or point me to an
> opensource php script which already does that so that I can analyse it.
>
In a single script it could be a little nasty if you want more then one
or two phases - its common to have a submit and view result on the same
script, but multiple stages can become a maintaince nightmare, but you
can do it like this:
You could use a "mode" indicator and a session settings. Look for
start_session() in the manual.
Something like:
<?php
start_session();
if(!isset($_SESSION['mode'])){
$_SESSION['mode'] = 0; // first time round, on first screen
}
// function to test if mode is 0 AND button pressed (ie a submission,
// deal (store) the information and increment mode
if($_SESSION['mode'] == 0){
?>
<form 1> </form 1>
<?php
} else if ($_SESSION['mode'] == 1) {
?>
<form 2> </form2>
<?php
}
?>
Navigation:
[Reply to this message]
|