I have a one question radio button form. I want the answer to immediately redirect to page A if the answer is A or redirect to page B if the answer is B. I know that the answer probably relies on javascript, but I am fairly new to coding and javascript is my Achilles' heel.
I have the form selecting and a basic if else statement - just not sure how to tie the two together. Some other questions here were helpful, just not enough to fully help me put something together. Here is my current code:
<?php
echo '<form id="gate" action="index.php" method="post">';
echo '<p>question<br>';
echo '<input type="radio" name="gateway" value="A">answer A<br>';
echo '<input type="radio" name="gateway" value="No">answer B<br>';
echo '</p>';
// branching for different forms
if($gateway=="Yes") {
header ('answer Yes url');
} else if($gateway=="No") {
header ('answer No url');
}
echo '</form>';
?>
</body>
</html>
I currently click on Yes or No and nothing happens. I would love some help connecting A and B to my statement. I would love to be able to do it without the user having to click Submit - have it redirect when they make the choice.
'; echo ' No
'; echo ''; if (isset($_POST)) { if($_POST['gateway'] == "Yes") { echo 'This sucks!'; // header('url'); die(); } else { echo 'I wish this would work!'; // header ('url'); die(); } } include '../footer.php'; `code` – learning_curve Mar 29 '19 at 16:50