Guest User

Untitled

a guest
Aug 1st, 2015
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. <?php
  2. // Cuerpo de funciones y codigo
  3.  
  4. // Base de palabras
  5. $palabras = array();
  6. $palabras[] = 'ogor';
  7. $palabras[] = 'ogo';
  8. //Rutina principal
  9. // Obtenemos los valores de la jugada
  10. $intento = isset($_REQUEST['intento']) ? $_REQUEST['intento'] : 0;
  11. $accion = isset($_REQUEST['accion']) ? $_REQUEST['accion'] : null;
  12. // Determinamos que hacer validando el botón de acción
  13. switch ($accion){
  14. case 'reset':
  15. $intento = 0;
  16. break;
  17.  
  18. case 'enviar':
  19. break;
  20.  
  21. default:
  22.  
  23. }
  24.  
  25. /*
  26. * Función para mostrar la palabra debe ajustarse para:
  27. * - Mostrar coincidencias
  28. * - Contar intentos fallidos
  29. */
  30.  
  31. function mostrar_palabra(){
  32. global $palabras;
  33. global $letras;
  34. // Cambiar este código para que traiga una palabra en modo random del arreglo $palabras
  35. $letras = str_split ( $palabras[mt_rand(0, (count($palabras)-1))]);
  36. $salida = "<table width='100%' border='1'><tr>";
  37. foreach ($letras as $k => $v){
  38. if (($_REQUEST['letra']) == $v){
  39. $salida .= "<td> $v </td>";
  40. }
  41. else
  42. {
  43. $salida .= "<td> __ </td>";
  44. }
  45.  
  46. }
  47. $salida .= "</tr></table>";
  48. //
  49. return $salida;
  50. }
  51.  
  52.  
  53. ?>
  54.  
  55. <HTML>
  56. <HEAD></HEAD>
  57. <BODY>
  58.  
  59. <form>
  60. <table align="center">
  61. <tr>
  62. <td colspan="4">ADIVINA LA PALABRA<td/>
  63. </tr>
  64.  
  65. <tr>
  66. <td>Ingrese la Letra:</td>
  67. <td><input type="text" name="letra" size="1" maxlength="1"></td>
  68. <td><input type="submit" name="accion" value="enviar"></td>
  69. <td><input type="submit" name="accion" value="reset"></td>
  70. </tr>
  71.  
  72. <tr>
  73. <td colspan="4"><?php echo mostrar_palabra(); ?><td/>
  74. </tr>
  75.  
  76. <tr>
  77. <td colspan="4"><img src="<?php echo $intento ?>.png" alt="intento"></table><td/>
  78. </tr>
  79.  
  80.  
  81. </table>
  82. <input type="hidden" name="intento" value="<?php echo $intento ?>">
  83. </form>
  84.  
  85. </BODY>
  86. </HTML>
Advertisement
Add Comment
Please, Sign In to add comment