Page 1 of 1

this is not working properly

Posted: Sat Dec 14, 2002 12:12 am
by harsha
<?php
$frm = $HTTP_GET_VARS['frm'];
$he= $HTTP_POST_VARS['he'];
switch ($frm)
{
case 'ome':
echo "<h1>this is the view page</h1>";
break;

case 'calc':
echo "aaa";
break;

default:
echo "<form action=\"{$PHP_SELF}?frm={$_POST['he']}\" method=\"post\">";
echo <<< HEHE
<input type="radio" name="he" value="ome" CHECKED><br>
<input type="radio" name="he" value="calc"><br>
<input type="submit" name="submit"><br>
HEHE;
echo "</form>";

break;

}
?>

Posted: Sat Dec 14, 2002 12:26 am
by nathus
what exactly is your error? am thinking it is this

Code: Select all

echo <<< HEHE 
<input type="radio" name="he" value="ome" CHECKED><br> 
<input type="radio" name="he" value="calc"><br> 
<input type="submit" name="submit"><br> 
HEHE;
maybe try this

Code: Select all

echo "<<< HEHE 
<input type="radio" name="he" value="ome" CHECKED><br> 
<input type="radio" name="he" value="calc"><br> 
<input type="submit" name="submit"><br> 
HEHE";
or alternatively

Code: Select all

?>
<<< HEHE 
<input type="radio" name="he" value="ome" CHECKED><br> 
<input type="radio" name="he" value="calc"><br> 
<input type="submit" name="submit"><br> 
HEHE
<?

problem is switch case

Posted: Sat Dec 14, 2002 12:34 am
by harsha
the problem is that if i submit the form the value in the radio button is
"ome" and the calc is not displayed even if i the calc radio button select

Posted: Sat Dec 14, 2002 12:37 am
by mydimension
no, his heredoc syntax is correct. its something else. my guess would be the way he uses the predefined global variables (ie. $HTTP_POST_VARS, $_POST, etc.) you should choose one or the other and stick with it. chances are that is what is messing your script up.

but again it would be helpful if you explained what your specific problem was and not just spit out code to us.

Posted: Sat Dec 14, 2002 1:00 am
by nathus
hmm, ok, didn't know about heredoc...anyway, I think I figured out whats up.

when its first submitted, its using action $PHP_SELF?frm= because nothing has been assigned to $_POST['he'] yet, so its a null string. and in the switch statement it uses $frm as the case to check, which the first time its submitted is empty, so goes back to default.

if you submit a second time, it works just fine.