UnKnowN Posted June 9, 2006 at 11:34 AM Report #32051 Posted June 9, 2006 at 11:34 AM O Que é que me falta aqui para que a opção apareça na caixa de texto ? <html> <body> <input name="opcao" type="radio" value="1" /> <input name="opcao" type="radio" value="2" /> <input name="opcao" type="reset" /> <input <?php $opcao = $_POST['opcao']; if ($opcao == 1){ $votar = 1; } else if ($opcao == 2) { $votar = 2; } echo $votar; ?> </body> </html>
kingless Posted June 9, 2006 at 12:11 PM Report #32054 Posted June 9, 2006 at 12:11 PM <?php $opcao = $_POST['opcao']; if(isset($_POST['enviar']) AND $opcao != "") { switch($opcao) { case 1: $votar = 1; break; case 2: $votar = 2; break; } echo $votar; } else { ?> <html> <body> <form method="post" action="<?__FILE__?>"> <input name="opcao" type="radio" value="1"> <input name="opcao" type="radio" value="2"> <input name="enviar" type="submit" value="Submeter"> <input name="reset" type="reset" value="Apagar"> </form> </body> </html> <? } ?> Ainda não testei mas acho que vai funcionar bem. O problema no teu codigo estava na "form" não colocaste, se quiseres aprender mais um pouco sobre isto tens aqui um pequeno tutorial http://phpbrasil.com/articles/article.php/id/719
UnKnowN Posted June 9, 2006 at 04:16 PM Author Report #32094 Posted June 9, 2006 at 04:16 PM Obrigadão kingless
pedrotuga Posted June 19, 2006 at 02:21 AM Report #33727 Posted June 19, 2006 at 02:21 AM podes antes usar a função empty() que serve especificamente para estas situações http://www.php.net/empty
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now