Advertisement
Guest User

Gues number

a guest
Feb 20th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. <?php
  2. $count = 0;
  3. $serchNumb = 0;
  4. $userNumb = 0;
  5. if( isset($_POST['submit'])){
  6. $serchNumb = $_POST['serchNumb']+0;
  7. $count = $_POST['count']+0;
  8. $count++;
  9. } else {
  10. $serchNumb = rand(1, 100);
  11. }
  12. if (isset($_POST['reset'])){
  13. $serchNumb = rand(1, 100);
  14. $count = 0;
  15. }
  16.  
  17. ?>
  18.  
  19. <!DOCTYPE html>
  20. <html>
  21. <head>
  22. <meta charset="UTF-8">
  23. <title>Insert title here</title>
  24. </head>
  25. <body>
  26.  
  27. <form action="./httHpm.php" method="post">
  28. <label for="">Try to guess?!?!</label>
  29.  
  30. <br/>
  31.  
  32. <input type="number" name="userNumb" />
  33. <input type="hidden" name="count" value="<?= $count ?>" />
  34. <input type="hidden" name="serchNumb" value="<?= $serchNumb ?>" />
  35.  
  36. <br/>
  37.  
  38. <input type="submit" name="submit" value="click!" />
  39.  
  40. <br/>
  41.  
  42. <?php
  43. if (isset($_POST['userNumb']) && is_numeric($_POST['userNumb']) ){
  44. $userNumb = $_POST['userNumb']+0;
  45.  
  46. if ($userNumb === $serchNumb){
  47. echo "<strong>Bravo, nameri chisloto!</strong> Uspeshno otkri chisloto za " . $count . " hoda!";
  48. echo "<br/>";
  49. echo " Sega opitaj da poznaesh novot ochislo ! :)";
  50. ?>
  51. <br>
  52. <input type="submit" name="reset" value="Try again!" />
  53.  
  54. <?php
  55. echo "<br/>";
  56. }
  57.  
  58. if ($userNumb > $serchNumb){
  59. echo "Opitai pak, chisloto e nadolu !";
  60. }
  61.  
  62. if ($userNumb < $serchNumb){
  63. echo "Opitaj pak, Chisloto e nagore!" ;
  64. }
  65. }
  66.  
  67.  
  68.  
  69. ?>
  70.  
  71. </form>
  72.  
  73. </body>
  74. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement