Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.51 KB | None | 0 0
  1. // тебе код чекав наче хатіко :(
  2. /*-------------------index1.php-----------------------------*/
  3. <?php
  4. session_start();
  5.  
  6. //$answers=array(3,1,2,1,2);
  7. $_SESSION['answers'] = array();
  8. ?>
  9.  
  10. <html>
  11. <head>
  12.  
  13. <title>
  14. </title>
  15. </head>
  16. <body>
  17.  
  18. <div>
  19. 1+3=?
  20.  
  21. <form method="POST" action="q_1.php">
  22. <input id="q1" value="1" type="radio"  name="q_1">1
  23. <input id="q1" value="2" type="radio"  name="q_1">2
  24. <input id="q1" value="3" type="radio"  name="q_1">4
  25. <input type="submit" value="ok">
  26.  
  27. </form>
  28.  
  29. </div>
  30.  
  31.  
  32.  
  33. </body>
  34.  
  35. </html>
  36.  
  37. /*-------------------q_1.php-----------------------------*/
  38. <?php
  39. session_start();
  40. $_SESSION['answers']['q1'] = $_POST['q_1'];
  41.  
  42. ?>
  43.  
  44. <form method="POST" action="q_2.php">
  45. <input id="q1" value="1" type="radio"  name="q_1">1
  46. <input id="q1" value="2" type="radio"  name="q_1">2
  47. <input id="q1" value="3" type="radio"  name="q_1">4
  48. <input type="submit" value="ok">
  49.  
  50. </form>
  51. /*-------------------q_2.php-----------------------------*/
  52. <?php
  53. session_start();
  54. $_SESSION['answers']['q2'] = $_POST['q_1'];
  55.  
  56. ?>
  57.  
  58. <form action='q_3.php' method="POST">
  59.     <input id="q2" value="1" type="radio"  name="q_1">1
  60.     <input id="q2" value="2" type="radio"  name="q_1">2
  61.     <input id="q2" value="3" type="radio"  name="q_1">4
  62.     <input type="submit" value="ok">
  63. </form>
  64. /*-------------------q_3.php-----------------------------*/
  65. <?php
  66. session_start();
  67. $_SESSION['answers']['q3'] = $_POST['q_1'];
  68.  
  69. ?>
  70.  
  71. <form action='q_4.php' method="POST">
  72.     <input id="q2" value="1" type="radio"  name="q_1">1
  73.     <input id="q2" value="2" type="radio"  name="q_1">2
  74.     <input id="q2" value="3" type="radio"  name="q_1">4
  75.     <input type="submit" value="ok">
  76. </form>
  77. /*-------------------q_4.php-----------------------------*/
  78. <?php
  79. session_start();
  80. $_SESSION['answers']['q4'] = $_POST['q_1'];
  81.  
  82. ?>
  83.  
  84. <form action='total.php' method="POST">
  85.     <input id="q4" value="1" type="radio"  name="q_1">1
  86.     <input id="q4" value="2" type="radio"  name="q_1">2
  87.     <input id="q4" value="3" type="radio"  name="q_1">4
  88.     <input type="submit" value="ok">
  89. </form>
  90. /*-------------------total.php-----------------------------*/
  91. <?php
  92. session_start();
  93. $_SESSION['answers']['q4']=$_POST['q_1'];
  94.  
  95.  
  96. $answer_list=array('q1'=>2,'q2'=>2,'q3'=>2,'q4'=>2);
  97.  
  98.  
  99. echo "Результаты:";
  100. echo "<pre>";
  101. print_r($_SESSION['answers']);
  102. echo "</pre>";
  103. // відповіді записано до $_SESSION['answers']
  104.  
  105.  
  106.  
  107.  
  108. session_destroy();
  109. //в кінці php файлу можна не використовувати ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement