RE: [PHP] Re: Loosing redirect in if...else

2004-03-12 Thread Alex Hogan
 (a) if you're using any values sent via the URL string (e.g.
 cf=0), you need to
 use $_GET, not $_POST;

Some of the information is coming from a form and the info from the url is
to call the different questions.  They are all on one page in a switch
statement.

 (b) empty() will also evaluate to true if the value of the variable 
 is zero.

That's right I forgot about that.  Thanks.



alex


** 
The contents of this e-mail and any files transmitted with it are 
confidential and intended solely for the use of the individual or 
entity to whom it is addressed.  The views stated herein do not 
necessarily represent the view of the company.  If you are not the 
intended recipient of this e-mail you may not copy, forward, 
disclose, or otherwise use it or any part of it in any form 
whatsoever.  If you have received this e-mail in error please 
e-mail the sender. 
** 




[PHP] Re: Loosing redirect in if...else

2004-03-11 Thread memoimyself
Hello Alex,

On 11 Mar 2004 at 10:15, Alex Hogan wrote:

 if(empty($_SESSION['sellocation'])){
 
 $_SESSION['selloction'] = '0';

Have a close look at the array member above. It's spelled differently from the others 
(an 
A is missing).

 
 }
 
 $_SESSION['sellocation'] = $_POST['sellocation'];
 
 
 if($_SESSION['sellocation'] == '0'){
 
 $errormsg = true;
 
 ?
 
 script
 
 redirect('cf_survey.php?cf=0');
 
 /script
 
 ?
 
 }
 
  
 
 [snip]
 
  
 
 a href=cf_survey.php?cf=1q1=1
 
  
 
 This seems to be where I run into trouble.
 
  
 
 When the user selects the main question choice and the page reloads I get an
 error that the index 'sellocation' is not set.
 
  
 
 If I change the expression to something like this;
 
  
 
 if(empty($_SESSION['sellocation'])){
 
 $_SESSION['selloction'] = '0';
 
 }
 
 else{
 
 $_SESSION['sellocation'] = $_POST['sellocation'];
 
 
 if($_SESSION['sellocation'] == '0'){
 
 $errormsg = true;
 
 ?
 
 script
 
 redirect('cf_survey.php?cf=0');
 
 /script
 
 ?
 
 }
 
  
 
 I loose the redirect on the drop down.
 
  
 
 What am I missing?

I'm having trouble understanding how your application works. For starters, I don't see 
where $POST['sellocation'] is being set, because you didn't provide us with that part 
of 
the code. It's true that, as it didn't make immediate sense to me, I didn't bother 
reading 
the code again because I don't have much time.

A couple of things off the top of my head that may or may not be related to your 
problem: (a) if you're using any values sent via the URL string (e.g. cf=0), you need 
to 
use $_GET, not $_POST; (b) empty() will also evaluate to true if the value of the 
variable 
is zero.

Good luck,

Erik