Re: [PHP] How do I initialize a page to do something ONCE

2002-11-22 Thread Jason Wong
On Friday 22 November 2002 07:26, [EMAIL PROTECTED] wrote:
 Hello,

 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:

 session_start();

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

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

 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.

OK, the only reason why the 2nd  IF block is not executed is if $initialize is 
not empty (ie isset($initialize) is TRUE hence $start_over = 1 is never 
executed). So try:

 if(!isset($initialize)) {
$start_over = 1; }
 else {
   var_dump($initialize); // to see what the  it contains
 }


-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
My BIOLOGICAL ALARM CLOCK just went off ... It has noiseless DOZE
FUNCTION and full kitchen!!
*/


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




RE: [PHP] How do I initialize a page to do something ONCE

2002-11-22 Thread @ Nilaab
The variable $initialize contains int(1), so it does set itself within the
last if statement. I'm just not sure why it's not unsetting all the sessions
when the page loads.

- Nilaab

 -Original Message-
 From: Jason Wong [mailto:[EMAIL PROTECTED]]
 Sent: Friday, November 22, 2002 2:36 AM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] How do I initialize a page to do something ONCE


 On Friday 22 November 2002 07:26, [EMAIL PROTECTED] wrote:
  Hello,
 
  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:
 
  session_start();
 
  if(!isset($initialize)) {
 $start_over = 1;
  }

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

  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.

 OK, the only reason why the 2nd  IF block is not executed is if
 $initialize is
 not empty (ie isset($initialize) is TRUE hence $start_over = 1 is never
 executed). So try:

  if(!isset($initialize)) {
 $start_over = 1; }
  else {
var_dump($initialize); // to see what the  it contains
  }


 --
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *

 /*
 My BIOLOGICAL ALARM CLOCK just went off ... It has noiseless DOZE
 FUNCTION and full kitchen!!
 */


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



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




RE: [PHP] How do I initialize a page to do something ONCE

2002-11-22 Thread Larry Brown
Your first post stated..
 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.


Your second sounds like it is executing the second block...

The variable $initialize contains int(1), so it does set itself within
the last if statement.

If the second block is being executed...

Did you check out php.net and the comments about session_unset()?

If it is not, are you closing the browser between tests?  The session
information stays open even after leaving the site and coming back.

Larry S. Brown
Dimension Networks, Inc.
(727) 723-8388





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




RE: [PHP] How do I initialize a page to do something ONCE

2002-11-22 Thread @ Nilaab
Jason Wong and Larry Brown,

Nevermind, it's working now. Not sure how. I performed the same test many
times, but this time when I tried it, it worked. It might be that I manually
deleted the older session variables. I did read the notes on php.net for
session_unset(), very informative. Thanks to both of you for your help.  :)

- Nilaab

 -Original Message-
 From: Larry Brown [mailto:[EMAIL PROTECTED]]
 Sent: Friday, November 22, 2002 9:31 AM
 To: PHP List; @ Nilaab
 Subject: RE: [PHP] How do I initialize a page to do something ONCE


 Your first post stated..
  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.
 

 Your second sounds like it is executing the second block...

 The variable $initialize contains int(1), so it does set itself within
 the last if statement.

 If the second block is being executed...

 Did you check out php.net and the comments about session_unset()?

 If it is not, are you closing the browser between tests?  The session
 information stays open even after leaving the site and coming back.

 Larry S. Brown
 Dimension Networks, Inc.
 (727) 723-8388







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