Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // тебе код чекав наче хатіко :(
- /*-------------------index1.php-----------------------------*/
- <?php
- session_start();
- //$answers=array(3,1,2,1,2);
- $_SESSION['answers'] = array();
- ?>
- <html>
- <head>
- <title>
- </title>
- </head>
- <body>
- <div>
- 1+3=?
- <form method="POST" action="q_1.php">
- <input id="q1" value="1" type="radio" name="q_1">1
- <input id="q1" value="2" type="radio" name="q_1">2
- <input id="q1" value="3" type="radio" name="q_1">4
- <input type="submit" value="ok">
- </form>
- </div>
- </body>
- </html>
- /*-------------------q_1.php-----------------------------*/
- <?php
- session_start();
- $_SESSION['answers']['q1'] = $_POST['q_1'];
- ?>
- <form method="POST" action="q_2.php">
- <input id="q1" value="1" type="radio" name="q_1">1
- <input id="q1" value="2" type="radio" name="q_1">2
- <input id="q1" value="3" type="radio" name="q_1">4
- <input type="submit" value="ok">
- </form>
- /*-------------------q_2.php-----------------------------*/
- <?php
- session_start();
- $_SESSION['answers']['q2'] = $_POST['q_1'];
- ?>
- <form action='q_3.php' method="POST">
- <input id="q2" value="1" type="radio" name="q_1">1
- <input id="q2" value="2" type="radio" name="q_1">2
- <input id="q2" value="3" type="radio" name="q_1">4
- <input type="submit" value="ok">
- </form>
- /*-------------------q_3.php-----------------------------*/
- <?php
- session_start();
- $_SESSION['answers']['q3'] = $_POST['q_1'];
- ?>
- <form action='q_4.php' method="POST">
- <input id="q2" value="1" type="radio" name="q_1">1
- <input id="q2" value="2" type="radio" name="q_1">2
- <input id="q2" value="3" type="radio" name="q_1">4
- <input type="submit" value="ok">
- </form>
- /*-------------------q_4.php-----------------------------*/
- <?php
- session_start();
- $_SESSION['answers']['q4'] = $_POST['q_1'];
- ?>
- <form action='total.php' method="POST">
- <input id="q4" value="1" type="radio" name="q_1">1
- <input id="q4" value="2" type="radio" name="q_1">2
- <input id="q4" value="3" type="radio" name="q_1">4
- <input type="submit" value="ok">
- </form>
- /*-------------------total.php-----------------------------*/
- <?php
- session_start();
- $_SESSION['answers']['q4']=$_POST['q_1'];
- $answer_list=array('q1'=>2,'q2'=>2,'q3'=>2,'q4'=>2);
- echo "Результаты:";
- echo "<pre>";
- print_r($_SESSION['answers']);
- echo "</pre>";
- // відповіді записано до $_SESSION['answers']
- session_destroy();
- //в кінці php файлу можна не використовувати ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement