The goal is to create four inline radio buttons, with a button to submit the form to a simple php script. The problem is that changing the name attribute from 'optradio' to something like 'small' breaks the switching between buttons.
The html:
<form action="logo-tshirt.php" method="post">
<label class="radio-inline"><input type="radio" name="small" value="1">S</label>
<label class="radio-inline"><input type="radio" checked name="medium" value="1">M</label>
<label class="radio-inline"><input type="radio" name="large" value="1">L</label>
<label class="radio-inline"><input type="radio" name="extra-large" value="1">XL</label><br />
<input style="margin-top:5px" type="submit" value="Buy With PayPal" name="send" class="btn btn-primary">
</form>
The php:
<?php
if($_POST['small'] == 1 ){
header("Location: http://www.google.com");
}
elseif($_POST['medium'] == 1 ){
header("Location: http://www.yahoo.com");
}
elseif($_POST['large'] == 1 ){
header("Location: http://www.bing.com");
}
elseif($_POST['extra-large'] == 1 ){
header("Location: http://www.bbc.co.uk");
}
else {
header("Location: http://www.theguardian.co.uk");
}
?>
Thanks for all the answers. The one i used was AI.G's because it used the least lines of code. This is my working code.
<form action="logo-tshirt.php" method="post">
<label class="radio-inline"><input type="radio" name="optradio" value="small">S</label>
<label class="radio-inline"><input checked type="radio" name="optradio" value="medium">M</label>
<label class="radio-inline"><input type="radio" name="optradio" value="large">L</label>
<label class="radio-inline"><input type="radio" name="optradio" value="extra-large">XL</label><br />
<input style="margin-top:5px" type="submit" value="Buy With PayPal" name="send" class="btn btn-primary">
</form>
The php:
<?php
switch ($_POST['optradio']) {
case "small": header("Location: http://www.google.com"); break;
case "medium": header("Location: http://www.yahoo.com"); break;
case "large": header("Location: http://www.bing.com"); break;
case "extra-large": header("Location: http://www.bbc.co.uk"); break;
default:header("Location: http://www.theguardian.co.uk"); /* if $_POST['option'] was none of the above */
}
?>