I have a newbie problem. I have an php page that has many layers of forms to
it. Once the user is finished with filling out one form and sending it,
another form appears. This is of course done using simple if-else or switch
statements. The problem is, how do I initialize a function or any other type
of process just ONCE for the entire page. I don't want the function or
process to run everytime a new form is displayed. Keep in mind that I'm also
using sessions for this. Here is a tiny stripped-down example, of my failed
attempt, that might help you analyze my question:


if(!isset($initialize)) {
   $start_over = 1;

// There were too many sessions to unregister,
// so I just used the session_unset() function and kept one necessary
// which is the login_id that is needed in order for the person to be able
// access this page, which they have gotten through authentication earlier:

if ($start_over == 1) {
   $temp_log = $logged_in;
   $logged_in = $temp_log;
   $initialize = 1;
   session_register("logged_in", "initialize");

if (!$submit1) {

        .. Display first form

elseif (!$submit2 && $submit1) {

        .. Display second form

elseif (!$submit3 && $submit1 && $submit2) {

        .. Display third form

elseif ($submit1 && $submit2 && $submit3) {

        .. Add To Database

There is the code/pseudo-code combination of what I have so far. The only
problem is that it is not processing the second if block -- if($start_over
== 1) -- unless I actually set start_over=1 in the get string. How would I
make sure that the page processes everything in that if block only ONCE
after the page first loads? Also, if anyone knows a better way of displaying
one form after another in on a single php page, I'm open to any ideas.

- Nilaab

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to