Here is a simple example of how to read the Radio Button in PHP.
HTML:
<form action="recebe.php">
<input type="radio" name="teste" value="um">Um<br>
<input type="radio" name="teste" value="dois">Dois<br>
<input type="radio" name="teste" value="três">Três<br>
</form>
PHP:
$escolha = @$_POST['teste']; // Usado @, já que vai ser testado em seguida.
if isempty( $escolha ) $pagina='URL da pagina padrao...';
else if $escolha == 'um' $pagina= 'URL da pagina um';
else if $escolha == 'dois' $pagina= 'URL da pagina dois';
else if $escolha == 'tres' $pagina= 'URL da pagina tres';
else $pagina = 'URL da pagina padrao, ou de erro';
...
Remembering that you can force one of the inputs to have the preselected value using checked
, but should check the case of being null anyway:
<input type="radio" name="teste" value="um" checked />Um<br>
// ^^^
If nothing is selected, the value of the radio will be null.
– gmsantos
Yes, I know that! But as I include a radio to each value found in the table, it will always be the same name, and the value appears as undefinid!
– Felipe
do an if to check if the value is different from Undefined
– gmsantos
Yes that’s right @Bacco!
– Felipe