Reply to Re: Many forms in one php file

Your name:

Reply:


Posted by James Taylor on 10/06/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
}
?>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация