Advertisement
Guest User

Untitled

a guest
Apr 27th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.11 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Submitted Information</title>
  4. </head>
  5.  
  6. <?php
  7. session_start();
  8. if ($_SESSION["Loggedin"] == 1){
  9. echo"Welcome $_SESSION[loggeduser] <br>";
  10. echo"You are currently Logged in <br>";
  11. echo"You have answered ";
  12. echo $_SESSION[counter];
  13. echo " questions <br>";
  14. if($_SESSION[counter] == 3) {
  15. echo "The correct answers were <br>";
  16. echo "Question1: ";
  17. echo $_SESSION[q1];
  18. echo "<br><br> Question2: ";
  19. echo $_SESSION[q2];
  20. echo"<br><br> Question3: ";
  21. echo $_SESSION[q3];
  22. echo" <br> How many did you get right? <br>";
  23. echo"<form action=\"http://busman.britafe.vic.edu.au/~10139010/Assessment3.php\" method=\"post\">";
  24. echo"<input type=\"submit\" name=\"logout2\" value=\"Logout\" />";
  25. echo"</form>";
  26. if(isset($_POST["logout2"])) {
  27. $_SESSION["Loggedin"] = 0;
  28. $_SESSION[counter] = o;
  29. header("Refresh:0");
  30.  
  31. } else{}
  32.  
  33. exit();
  34. }else{}
  35. if($_SESSION[answer1] == 0){
  36. $db = mysql_connect("localhost", "jonathanb", "4EHKh6")
  37. or die("Could not connect: " . mysql_error() );
  38. mysql_select_db("DB_jonathanb", $db)
  39. or die("Could not find database");
  40.  
  41. $dbRecords = mysql_query("SELECT * FROM questions where ID = 3", $db)
  42. or die("Problem reading table: " . mysql_error() );
  43.  
  44. $arrRecord = mysql_fetch_row($dbRecords);
  45.  
  46. echo "<br> Question 3";
  47. echo "<dl>\n\n<dt>" . $arrRecord[1] . "</dt>\n";
  48. echo "<dd>\n";
  49. echo "<input type=\"radio\" name=\"ans\" value=\"1\" id=\"ans\">" .
  50. $arrRecord[2] . "<br />\n";
  51. echo "<input type=\"radio\" name=\"ans\" value=\"2\" id=\"ans\">" .
  52. $arrRecord[3] . "<br />\n";
  53. echo "<input type=\"radio\" name=\"ans\" value=\"3\" id=\"ans\">" .
  54. $arrRecord[4] . "<br />\n";
  55. echo "<input type=\"radio\" name=\"ans\" value=\"4\" id=\"ans\">" .
  56. $arrRecord[5] . "<br />\n";
  57. echo "</dd>\n";
  58. echo "</dl>\n";
  59. echo $_SESSION[answer1];
  60. echo"<form action=\"http://busman.britafe.vic.edu.au/~10139010/Assessment3.php\" method=\"post\">";
  61. echo"<input type=\"submit\" name=\"Question\" value=\"Submit\" />";
  62. echo"</form>";
  63. if(isset($_POST["Question"])) {
  64. $_SESSION[answer1] = 1;
  65. $_SESSION[q1] = $arrRecord[2];
  66. ++$_SESSION[counter];
  67. header("Refresh:0");
  68.  
  69. } else{}
  70. echo"<form action=\"http://busman.britafe.vic.edu.au/~10139010/Assessment3.php\" method=\"post\">";
  71. echo"<input type=\"submit\" name=\"logout2\" value=\"Logout\" />";
  72. echo"</form>";
  73. if(isset($_POST["logout2"])) {
  74. $_SESSION["Loggedin"] = 0;
  75. header("Refresh:0");
  76.  
  77. } else{}
  78. } elseif($_SESSION[answer1] == 1){
  79. $db = mysql_connect("localhost", "jonathanb", "4EHKh6")
  80. or die("Could not connect: " . mysql_error() );
  81. mysql_select_db("DB_jonathanb", $db)
  82. or die("Could not find database");
  83.  
  84. $dbRecords = mysql_query("SELECT * FROM questions where ID = 2", $db)
  85. or die("Problem reading table: " . mysql_error() );
  86.  
  87. $arrRecord = mysql_fetch_row($dbRecords);
  88. echo "<br> Question 2";
  89. echo "<dl>\n\n<dt>" . $arrRecord[1] . "</dt>\n";
  90. echo "<dd>\n";
  91. echo "<input type=\"radio\" name=\"ans\" value=\"1\" id=\"ans\">" .
  92. $arrRecord[2] . "<br />\n";
  93. echo "<input type=\"radio\" name=\"ans\" value=\"2\" id=\"ans\">" .
  94. $arrRecord[3] . "<br />\n";
  95. echo "<input type=\"radio\" name=\"ans\" value=\"3\" id=\"ans\">" .
  96. $arrRecord[4] . "<br />\n";
  97. echo "<input type=\"radio\" name=\"ans\" value=\"4\" id=\"ans\">" .
  98. $arrRecord[5] . "<br />\n";
  99. echo "</dd>\n";
  100. echo "</dl>\n";
  101.  
  102. echo $_SESSION[answer1];
  103. echo"<form action=\"http://busman.britafe.vic.edu.au/~10139010/Assessment3.php\" method=\"post\">";
  104. echo"<input type=\"submit\" name=\"Question\" value=\"Submit\" />";
  105. echo"</form>";
  106. if(isset($_POST["Question"])) {
  107. $_SESSION[answer1] = 2;
  108. $_SESSION[q2] = $arrRecord[2];
  109. ++$_SESSION[counter];
  110. header("Refresh:0");
  111. }
  112.  
  113. echo"<form action=\"http://busman.britafe.vic.edu.au/~10139010/Assessment3.php\" method=\"post\">";
  114. echo"<input type=\"submit\" name=\"logout2\" value=\"Logout\" />";
  115. echo"</form>";
  116. if(isset($_POST["logout2"])) {
  117. $_SESSION["Loggedin"] = 0;
  118. header("Refresh:0");
  119.  
  120. } else{}
  121. } elseif($_SESSION[answer1] == 2){
  122. $db = mysql_connect("localhost", "jonathanb", "4EHKh6")
  123. or die("Could not connect: " . mysql_error() );
  124. mysql_select_db("DB_jonathanb", $db)
  125. or die("Could not find database");
  126.  
  127. $dbRecords = mysql_query("SELECT * FROM questions where ID = 1", $db)
  128. or die("Problem reading table: " . mysql_error() );
  129.  
  130. $arrRecord = mysql_fetch_row($dbRecords);
  131.  
  132. echo "<br> Question 1 ";
  133. echo "<dl>\n\n<dt>" . $arrRecord[1] . "</dt>\n";
  134. echo "<dd>\n";
  135. echo "<input type=\"radio\" name=\"ans\" value=\"1\" id=\"ans\">" .
  136. $arrRecord[2] . "<br />\n";
  137. echo "<input type=\"radio\" name=\"ans\" value=\"2\" id=\"ans\">" .
  138. $arrRecord[3] . "<br />\n";
  139. echo "<input type=\"radio\" name=\"ans\" value=\"3\" id=\"ans\">" .
  140. $arrRecord[4] . "<br />\n";
  141. echo "<input type=\"radio\" name=\"ans\" value=\"4\" id=\"ans\">" .
  142. $arrRecord[5] . "<br />\n";
  143. echo "</dd>\n";
  144. echo "</dl>\n";
  145. echo $_SESSION[answer1];
  146. echo"<form action=\"http://busman.britafe.vic.edu.au/~10139010/Assessment3.php\" method=\"post\">";
  147. echo"<input type=\"submit\" name=\"Question\" value=\"Submit\" />";
  148. echo"</form>";
  149. if(isset($_POST["Question"])) {
  150. $_SESSION[answer1] = 0;
  151. $_SESSION[q3] = $arrRecord[2];
  152. ++$_SESSION[counter];
  153. header("Refresh:0");
  154. } else{}
  155. echo"<form action=\"http://busman.britafe.vic.edu.au/~10139010/Assessment3.php\" method=\"post\">";
  156. echo"<input type=\"submit\" name=\"logout2\" value=\"Logout\" />";
  157. echo"</form>";
  158. if(isset($_POST["logout2"])) {
  159. $_SESSION["Loggedin"] = 0;
  160. header("Refresh:0");
  161.  
  162. } else{}
  163. }else{echo $_SESSION[answer1];
  164. }
  165. exit();
  166. }else{}
  167. $p1 = "pass1";
  168. $p2 = "pass2";
  169. $passone = md5($p1);
  170. $passtwo = md5($p2);
  171. $users = array ("User1"=>"$passone","User2"=>"$passtwo");
  172. if(isset($_POST["submit"])) {
  173. if (strlen($_POST["Username"]) < 1) {
  174. echo "Please enter Valid Username";
  175. } elseif (strlen($_POST["Password"]) < 1) {
  176. echo "Please Enter Valid Password";
  177. }else{
  178. $user = $_POST["Username"];
  179. $pass = $_POST["Password"] ;
  180. $mdpass = md5($pass);
  181. foreach($users as $x => $x_value) {
  182. if ($x === $user && $mdpass === $x_value) {
  183. echo "Success <br />";
  184. $_SESSION["Loggedin"] = 1;
  185. $_SESSION[answer1] = rand(0,2);
  186. $_SESSION[counter] = 0;
  187. header("Refresh:0");
  188. exit();
  189.  
  190. }
  191. else {}
  192. }
  193. echo "Unable to Login..Invalid Format or Wrong Details";
  194. }
  195. }
  196. ?>
  197. <body>
  198.  
  199. <form action="http://busman.britafe.vic.edu.au/~10139010/Assessment3.php"
  200. method="post">
  201.  
  202. <label for="Username">Username: </label>
  203. <input type="text" name="Username"
  204. id="Username" size="25" maxlength="100" /><br />
  205.  
  206. <label for="Password">Password: </label>
  207. <input type="text" name="Password"
  208. id="Password" size="25" maxlength="100" /><br />
  209.  
  210. <input type="submit" name="submit" />
  211. </form>
  212. </body>
  213. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement