Created
June 15, 2015 22:04
-
-
Save porfidev/f2ed7e33c80d3053267e to your computer and use it in GitHub Desktop.
Un switch básico de HTML y PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
<title></title> | |
</head> | |
<body> | |
<form name="leformulario" id="leformulario" action="leguardado.php" method="post"> | |
<label for="miopcionelegida1"> | |
Opcion valor 1 | |
<input name="miopcionelegida" id="miopcionelegida1" type="radio" value="1" checked> | |
</label> | |
<br> | |
<label for="miopcionelegida2"> | |
Opcion valor 2 | |
<input name="miopcionelegida" id="miopcionelegida2" type="radio" value="2"> | |
</label> | |
<br> | |
<label for="miopcionelegida3"> | |
Opcion valor 3 | |
<input name="miopcionelegida" id="miopcionelegida3" type="radio" value="3"> | |
</label> | |
<br> | |
<label for="miopcionelegida4"> | |
Opcion valor 4 | |
<input name="miopcionelegida" id="miopcionelegida4" type="radio" value="4"> | |
</label> | |
<button type="submit">gomu gomu no guardar</button> | |
</form> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by PhpStorm. | |
* User: elporfirio | |
* Date: 15/06/2015 | |
* Time: 04:50 PM | |
*/ | |
$opcion = array_key_exists('miopcionelegida',$_POST) ? $_POST['miopcionelegida'] : null; | |
$texto = "La opción elegida es: "; | |
switch($opcion){ | |
case '1': | |
$texto .= "uno"; | |
break; | |
case '2': | |
$texto .= "dos"; | |
break; | |
case '3': | |
$texto .= "tres"; | |
break; | |
case '4': | |
$texto .= "cuatro"; | |
break; | |
default: | |
$texto = "No se eligio opción valida"; | |
break; | |
} | |
echo $texto; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment