<?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;
}
?>
this is not working properly
Moderator: General Moderators
what exactly is your error? am thinking it is this
maybe try this
or alternatively
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;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";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
<?- harsha
- Forum Contributor
- Posts: 103
- Joined: Thu Jul 11, 2002 1:35 am
- Location: Bengaluru (Bangalore) > Karnataka > India
problem is switch case
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
"ome" and the calc is not displayed even if i the calc radio button select
- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
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.
but again it would be helpful if you explained what your specific problem was and not just spit out code to us.
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.
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.