PageRenderTime 52ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/account.php

https://bitbucket.org/rkrebbers/homework-final
PHP | 51 lines | 45 code | 6 blank | 0 comment | 2 complexity | 7e22d540745f8e2ac886be4647c0c6e1 MD5 | raw file
  1. <?php
  2. session_start(); // NEVER forget this!
  3. include ('database_connection.php');
  4. include ('functions.php');
  5. if(!isset($_SESSION['loggedin']))
  6. {
  7. die("To access this page, you need to <a href='index.php'>LOGIN</a>"); // Make sure they are logged in!
  8. } // What the !isset() code does, is check to see if the variable $_SESSION['loggedin'] is there, and if it isn't it kills the script telling the user to log in!
  9. ?>
  10. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  11. <html xmlns="http://www.w3.org/1999/xhtml">
  12. <head>
  13. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  14. <title>User Account</title>
  15. <link rel="stylesheet" href="quiz.css" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="container">
  19. <h1>DB-Web Portal</h1>
  20. <hr>
  21. <?php
  22. echo "Hello there, <b>{$_SESSION['name']}!</b>";
  23. $query_bestscore = "select best_score from dbhomework.users where name=\"{$_SESSION["name"]}\"";
  24. $handle = mysql_query($query_bestscore) or die(mysql_error());
  25. while($row = mysql_fetch_assoc($handle)){
  26. $bestscore = $row["best_score"];
  27. }
  28. if(empty($bestscore)){
  29. echo "<p>You have not yet completed the quiz. Please do this below.</p>";
  30. $bestscore=-1;
  31. }
  32. else{
  33. echo "<p>Your best quiz score is: $bestscore points.</p>";
  34. $_SESSION["bestscore"] = $bestscore;
  35. }
  36. echo "<p>". hallOfFame() . "</p>";
  37. ?>
  38. <p>To do the online quiz, please click the following link below</p>
  39. <a href='quiz.php'>Quiz</a>
  40. <hr>
  41. <p>If you wish to log out, please click on the link below</p>
  42. <a href='logout.php'>Log Out</a>
  43. </div>
  44. </body>
  45. </html>