To $_POST or not to $_POST ... Help me please.
Posted: Mon May 06, 2002 2:13 pm
I have the following:
But i cannot get the following to work:
I have tried putting $_POST in the switch like this:
But this stops the swicth from working.
Please could someone give me a hand as i am very new to PHP, only started learning a few days ago.
:0)
Code: Select all
<?php
//Section 1
function S1Q1(){
global $PHP_SELF;
global $S1Q1;
global $S1Q1;
?>
<form name="form1" method="post" action="<?php echo $PHP_SELF; ?>">
Section 1<hr> <br>
Do you play computer games? <br>
Yes
<input type="radio" name="S1Q1" value="Yes">
No
<input type="radio" name="S1Q1" value="No">
<br><br>
Why dont you play computer games? (More than one can be selected)
<br>
They are boring<br>
<input type="checkbox" name="S1Q2" value="S1Q2(A)">
<br>
They are too expensive<br>
<input type="checkbox" name="S1Q2" value="S1Q2(B)">
<br>
I have better things to do with my time<br>
<input type="checkbox" name="S1Q2" value="S1Q2(C)">
<input type="hidden" name="stage" value="2">
<br>
<input type="submit" name="Submit" value="Submit">
</form>
</form>
<?php
}
?>
?>
<?php
//Section 2
Function S2Q1(){
global $question1;
global $S1Q1;
global $S1Q2;
global $PHP_SELF;
global $_POST;
?>
<form name="form1" method="post" action="<?php echo $PHP_SELF; ?>">
Section 2 <input type="text" name="question2">
<input type="hidden" name="S1Q1" value="<?php echo htmlspecialchars($S1Q1); ?>">
<input type="hidden" name="S1Q2" value="<?php echo htmlspecialchars($S1Q2); ?>">
<?php
while (list($k, $v) = each($_POST))
{
print("<input type=hidden name="$k" value="".htmlspecialchars($v)."">
");
}
?>
<input type="submit" name="Submit" value="Submit">
<input type="hidden" name="stage" value="3">
</form>
<?php
}
?>
?>
<?php
<?php
//Section 3
Function S3Q1(){
global $question1;
global $S1Q1;
global $S1Q2;
global $PHP_SELF;
global $HTTP_POST_VARS;
?>
Section 3<hr><br>
3. Why don't you play computer games? (More than one can be selected)
<br>
<form name="form1" method="post" action="<?php echo $PHP_SELF; ?>">
I don't have a computer/console<br>
<input type="checkbox" name="S1Q3" value="S1Q3(A)"><br>
Playing interactive games is unsociable<br>
<input type="checkbox" name="S1Q3" value="S1Q3(B)"><br>
Playing interactive games is boring<br>
<input type="checkbox" name="S1Q3" value="S1Q3(C)"><br>
Playing interactive games is geeky<br>
<input type="checkbox" name="S1Q3" value="S1Q3(D)"><br>
They're expensive<br>
<input type="checkbox" name="S1Q3" value="S1Q3(E)"><br>
I have never had the opportunity<br>
<input type="checkbox" name="S1Q3" value="S1Q3(F)"><br>
I don't have the time<br>
<input type="checkbox" name="S1Q3" value="S1Q3(G)"><br>
Other<br>
<input type="checkbox" name="S1Q3" value="S1Q3(H)"><br>
<?php
$pr= current($HTTP_POST_VARS);
do
{
print("$pr");
}
while($pr=next($HTTP_POST_VARS))
?>
<input type="submit" name="Submit" value="Submit">
<input type="hidden" name="stage" value="3">
</form>
<?php
}
?>
?>
<?php
<?php
// Determine the sections to diplay
// Determine the sections to diplay
switch ($stage) {
case "2":
if ($S1Q1 == "No"){
S3Q1();
S3Q1();
}
else {
S2Q1();
}
break;
case "3":
print ("You have said you do not play computer games");
break;
case "done":
Print("Thank You for your answers");
break;
default:
S1Q1();
}
?>Code: Select all
<?php
while (list($k, $v) = each($_POST))
{
print("<input type=hidden name="$k" value="".htmlspecialchars($v)."">
");
}
?>Code: Select all
switch ($_POSTї'stage']) {Please could someone give me a hand as i am very new to PHP, only started learning a few days ago.
:0)