I have a login form and a section with 3 checkboxes and a final submit button. I want to write code such that when a checkbox is checked, and the submit button is clicked, the user will be redirected to another page depending on which checkbox was checked.
I have:
<input type="checkbox" name="gender" value="male">
<input type="checkbox" name="gender" value="female">
I know that you can use
if (isset($_POST['male'])) {
// Checkbox male is selected
} else {
// Do something else
}
To see if the checkbox is checked, and
<input type="button" value="goElsewhere" class="GE" id="GELSEWHERE"
onClick="Javascript:window.location.href = 'http://www.google.com';" />
For a page redirect when the button is clicked.
But I'm not sure how to combine these. How would I go about it?
Edit: The page should redirect only after the final submit button is clicked. The checkboxes should only determine which page the user is directed to. Checking a checkbox should not redirect the page.