It can either be done server-side, using PHP, or client-side, using JavaScript. I would recommend the latter, but I'll explain both possibilities:
The HTML:
HTML Code:
<form action="goto.php" method="get" id="gotoform">
<input type="submit" value="Go" />
Go to: <input type="checkbox" name="goto" value="admin" checked="checked" /> admin <input type="checkbox" name="goto" value="home" /> home
If you chose to use PHP, this is what you would put in goto.php:
PHP Code:
<?php
if ($_GET['goto'] === 'admin') {
header('Location: admin.php');
} else if ($_GET['goto'] === 'home') {
header('Location: index.php');
} else {
echo 'Invalid input.';
}
Using JavaScript:
Code:
document.getElementById('gotoform').addEventListener('submit', function(e) {
for (var goto = '', i = 0; i < this.goto.length; i++) {
if (this.goto[i].checked) {
goto = this.goto[i].value;
break;
}
}
if (goto === 'admin') {
document.location = 'admin.php';
} else if (goto === 'home') {
document.location = 'index.php';
} else {
alert('Invalid input');
}
e.preventDefault();
});