vendredi 29 mars 2019

I need the answer from a form to immediately redirect to another form

I have a one question radio button form. I want the answer to immediately redirect to page A if answer is A or redirect to page B if 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
include '../header.php';
echo '<h2>Conference Registration Form</h2>';

echo '<p>Please fill out the form below.  If you have any questions or problems, please contact us at 123.456.7890.</p>';
echo '<p style="font-weight: bold;">Note: additional options will appear as you fill out the form.</p>';
echo '<p>All prices are in US dollars.</p>';
echo '<form id="gate" action="index.php" method="post">';
echo '<p>I work at Teflon as a faculty member, staff member, or graduate student.<br>';
echo '<input type="radio" name="gateway" value="Yes"> Yes<br>';
echo '<input type="radio" name="gateway" value="No"> No<br>';
echo '</p>';

// branching for different forms
if($gateway=="Yes") {
            header ('answer Yes url');

} else if($gateway=="No") {
            header ('answer No url');

         }    
    echo '</form>';
    echo '<div class="clear"></div>';
    echo '</div>';
    echo '</div>';          

include '../footer.php';
?>
</body>
</html>
`````````````

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.

Aucun commentaire:

Enregistrer un commentaire