Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Submitted Information</title>
- </head>
- <?php
- session_start();
- if ($_SESSION["Loggedin"] == 1){
- echo"Welcome $_SESSION[loggeduser] <br>";
- echo"You are currently Logged in <br>";
- echo"You have answered ";
- echo $_SESSION[counter];
- echo " questions <br>";
- if($_SESSION[counter] == 3) {
- echo "The correct answers were <br>";
- echo "Question1: ";
- echo $_SESSION[q1];
- echo "<br><br> Question2: ";
- echo $_SESSION[q2];
- echo"<br><br> Question3: ";
- echo $_SESSION[q3];
- echo" <br> How many did you get right? <br>";
- echo"<form action=\"http://busman.britafe.vic.edu.au/~10139010/Assessment3.php\" method=\"post\">";
- echo"<input type=\"submit\" name=\"logout2\" value=\"Logout\" />";
- echo"</form>";
- if(isset($_POST["logout2"])) {
- $_SESSION["Loggedin"] = 0;
- $_SESSION[counter] = o;
- header("Refresh:0");
- } else{}
- exit();
- }else{}
- if($_SESSION[answer1] == 0){
- $db = mysql_connect("localhost", "jonathanb", "4EHKh6")
- or die("Could not connect: " . mysql_error() );
- mysql_select_db("DB_jonathanb", $db)
- or die("Could not find database");
- $dbRecords = mysql_query("SELECT * FROM questions where ID = 3", $db)
- or die("Problem reading table: " . mysql_error() );
- $arrRecord = mysql_fetch_row($dbRecords);
- echo "<br> Question 3";
- echo "<dl>\n\n<dt>" . $arrRecord[1] . "</dt>\n";
- echo "<dd>\n";
- echo "<input type=\"radio\" name=\"ans\" value=\"1\" id=\"ans\">" .
- $arrRecord[2] . "<br />\n";
- echo "<input type=\"radio\" name=\"ans\" value=\"2\" id=\"ans\">" .
- $arrRecord[3] . "<br />\n";
- echo "<input type=\"radio\" name=\"ans\" value=\"3\" id=\"ans\">" .
- $arrRecord[4] . "<br />\n";
- echo "<input type=\"radio\" name=\"ans\" value=\"4\" id=\"ans\">" .
- $arrRecord[5] . "<br />\n";
- echo "</dd>\n";
- echo "</dl>\n";
- echo $_SESSION[answer1];
- echo"<form action=\"http://busman.britafe.vic.edu.au/~10139010/Assessment3.php\" method=\"post\">";
- echo"<input type=\"submit\" name=\"Question\" value=\"Submit\" />";
- echo"</form>";
- if(isset($_POST["Question"])) {
- $_SESSION[answer1] = 1;
- $_SESSION[q1] = $arrRecord[2];
- ++$_SESSION[counter];
- header("Refresh:0");
- } else{}
- echo"<form action=\"http://busman.britafe.vic.edu.au/~10139010/Assessment3.php\" method=\"post\">";
- echo"<input type=\"submit\" name=\"logout2\" value=\"Logout\" />";
- echo"</form>";
- if(isset($_POST["logout2"])) {
- $_SESSION["Loggedin"] = 0;
- header("Refresh:0");
- } else{}
- } elseif($_SESSION[answer1] == 1){
- $db = mysql_connect("localhost", "jonathanb", "4EHKh6")
- or die("Could not connect: " . mysql_error() );
- mysql_select_db("DB_jonathanb", $db)
- or die("Could not find database");
- $dbRecords = mysql_query("SELECT * FROM questions where ID = 2", $db)
- or die("Problem reading table: " . mysql_error() );
- $arrRecord = mysql_fetch_row($dbRecords);
- echo "<br> Question 2";
- echo "<dl>\n\n<dt>" . $arrRecord[1] . "</dt>\n";
- echo "<dd>\n";
- echo "<input type=\"radio\" name=\"ans\" value=\"1\" id=\"ans\">" .
- $arrRecord[2] . "<br />\n";
- echo "<input type=\"radio\" name=\"ans\" value=\"2\" id=\"ans\">" .
- $arrRecord[3] . "<br />\n";
- echo "<input type=\"radio\" name=\"ans\" value=\"3\" id=\"ans\">" .
- $arrRecord[4] . "<br />\n";
- echo "<input type=\"radio\" name=\"ans\" value=\"4\" id=\"ans\">" .
- $arrRecord[5] . "<br />\n";
- echo "</dd>\n";
- echo "</dl>\n";
- echo $_SESSION[answer1];
- echo"<form action=\"http://busman.britafe.vic.edu.au/~10139010/Assessment3.php\" method=\"post\">";
- echo"<input type=\"submit\" name=\"Question\" value=\"Submit\" />";
- echo"</form>";
- if(isset($_POST["Question"])) {
- $_SESSION[answer1] = 2;
- $_SESSION[q2] = $arrRecord[2];
- ++$_SESSION[counter];
- header("Refresh:0");
- }
- echo"<form action=\"http://busman.britafe.vic.edu.au/~10139010/Assessment3.php\" method=\"post\">";
- echo"<input type=\"submit\" name=\"logout2\" value=\"Logout\" />";
- echo"</form>";
- if(isset($_POST["logout2"])) {
- $_SESSION["Loggedin"] = 0;
- header("Refresh:0");
- } else{}
- } elseif($_SESSION[answer1] == 2){
- $db = mysql_connect("localhost", "jonathanb", "4EHKh6")
- or die("Could not connect: " . mysql_error() );
- mysql_select_db("DB_jonathanb", $db)
- or die("Could not find database");
- $dbRecords = mysql_query("SELECT * FROM questions where ID = 1", $db)
- or die("Problem reading table: " . mysql_error() );
- $arrRecord = mysql_fetch_row($dbRecords);
- echo "<br> Question 1 ";
- echo "<dl>\n\n<dt>" . $arrRecord[1] . "</dt>\n";
- echo "<dd>\n";
- echo "<input type=\"radio\" name=\"ans\" value=\"1\" id=\"ans\">" .
- $arrRecord[2] . "<br />\n";
- echo "<input type=\"radio\" name=\"ans\" value=\"2\" id=\"ans\">" .
- $arrRecord[3] . "<br />\n";
- echo "<input type=\"radio\" name=\"ans\" value=\"3\" id=\"ans\">" .
- $arrRecord[4] . "<br />\n";
- echo "<input type=\"radio\" name=\"ans\" value=\"4\" id=\"ans\">" .
- $arrRecord[5] . "<br />\n";
- echo "</dd>\n";
- echo "</dl>\n";
- echo $_SESSION[answer1];
- echo"<form action=\"http://busman.britafe.vic.edu.au/~10139010/Assessment3.php\" method=\"post\">";
- echo"<input type=\"submit\" name=\"Question\" value=\"Submit\" />";
- echo"</form>";
- if(isset($_POST["Question"])) {
- $_SESSION[answer1] = 0;
- $_SESSION[q3] = $arrRecord[2];
- ++$_SESSION[counter];
- header("Refresh:0");
- } else{}
- echo"<form action=\"http://busman.britafe.vic.edu.au/~10139010/Assessment3.php\" method=\"post\">";
- echo"<input type=\"submit\" name=\"logout2\" value=\"Logout\" />";
- echo"</form>";
- if(isset($_POST["logout2"])) {
- $_SESSION["Loggedin"] = 0;
- header("Refresh:0");
- } else{}
- }else{echo $_SESSION[answer1];
- }
- exit();
- }else{}
- $p1 = "pass1";
- $p2 = "pass2";
- $passone = md5($p1);
- $passtwo = md5($p2);
- $users = array ("User1"=>"$passone","User2"=>"$passtwo");
- if(isset($_POST["submit"])) {
- if (strlen($_POST["Username"]) < 1) {
- echo "Please enter Valid Username";
- } elseif (strlen($_POST["Password"]) < 1) {
- echo "Please Enter Valid Password";
- }else{
- $user = $_POST["Username"];
- $pass = $_POST["Password"] ;
- $mdpass = md5($pass);
- foreach($users as $x => $x_value) {
- if ($x === $user && $mdpass === $x_value) {
- echo "Success <br />";
- $_SESSION["Loggedin"] = 1;
- $_SESSION[answer1] = rand(0,2);
- $_SESSION[counter] = 0;
- header("Refresh:0");
- exit();
- }
- else {}
- }
- echo "Unable to Login..Invalid Format or Wrong Details";
- }
- }
- ?>
- <body>
- <form action="http://busman.britafe.vic.edu.au/~10139010/Assessment3.php"
- method="post">
- <label for="Username">Username: </label>
- <input type="text" name="Username"
- id="Username" size="25" maxlength="100" /><br />
- <label for="Password">Password: </label>
- <input type="text" name="Password"
- id="Password" size="25" maxlength="100" /><br />
- <input type="submit" name="submit" />
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement