i was wondering how to create a dynamic post action in a form using php. i have several radio buttons on this form with values from A to H. if the user selects A, they should be directed to page2.php, however any other option should take them to more.php. i have done an "if/else" like this:
and then in the form i did this:
the problem is, since the php is processed before the page loads, the action in the form tag is always more.php and i am never able to get to page2.php. (because Q1 is never equal to A when the page loads.)
how do i dynamically set the action on the form tag?
Code:
<?PHP if ($Q1 == "A")
{
$answer="page2.php";
}
else
{
$answer="more.php";
}
?>
Code:
<form name="form1" method="post" action="<?PHP echo $answer; ?>">
the problem is, since the php is processed before the page loads, the action in the form tag is always more.php and i am never able to get to page2.php. (because Q1 is never equal to A when the page loads.)
how do i dynamically set the action on the form tag?