Page 1 of 1

if statement question

Posted: Thu Dec 25, 2008 10:35 am
by chopper_pc
Im trying to write a script that takes two post values from drop down forms on the previous page and sets a variable to be used in the "action" part of a form on the page to control direction of the submit. The purpose is the value of the drop downs is zero if not used, I want to change the direction of the page if both drop downs are not used.

Code: Select all

 
$id1=$_POST['id1'];
$id2=$_POST['id2'];
if($id1 == 0 and $id2 == 0) {
$action="foo";
    } else {
$action="foo2";
blablabla
<form action="<? echo $action?>.php" method="post">
    }
I don't know what i'm missing but the script is going to foo2 even if both values are 0.
I have confirmed the values posted are 0 by echoing them in the page.
Is there somthing simple I am missing?

Re: if statement question

Posted: Thu Dec 25, 2008 3:00 pm
by aditya2071990
The else's ending brace is after the form tag... maybe that's the problem?