Advertisement
Guest User

Untitled

a guest
Jun 26th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. <DOCTYPE html>
  2. <head />
  3. <title> ans check </title>
  4. <body>
  5. <?php
  6. include('session.php');
  7. if (isset($_POST['submit'])) {
  8. if (empty($_POST['ans']))
  9. {
  10. echo"<h1> You didn't answer....sorry we consider this as wrong ans</h1>";
  11. ?>
  12. <form action="score.php" method="post">
  13. <input name="submit" type="submit" value=" Proceed... ">
  14. <?php
  15. }
  16. else{
  17. $servername = "localhost";
  18. $username = "root";
  19. $password = "";
  20. $dbname = "details";
  21.  
  22. $ans=$_POST['ans'];
  23. $conn=mysqli_connect($servername, $username, $password, $dbname);
  24. $sql="select * from profile where username='$login_session' and password='$login_pass'";
  25. $result=mysqli_query($conn, $sql);
  26. if (mysqli_num_rows($result) > 0) {
  27. $row = mysqli_fetch_assoc($result);
  28. $level=$row["level"];
  29. $score=$row["score"];
  30. }
  31.  
  32. $sql="select ans from question where level='$level'";
  33. $result=mysqli_query($conn, $sql);
  34. if (mysqli_num_rows($result) > 0) {
  35. $row = mysqli_fetch_assoc($result);
  36. $c_ans=$row["ans"];
  37. }
  38. if($c_ans==$ans){
  39. echo "<i><h1>Congrats you are advancing to the next level</h1></i>";
  40. $score=$score+10;
  41. $sql="update profile set score='$score' where username='$login_session' and password='$login_pass'";
  42. $result=mysqli_query($conn, $sql);
  43. ?><form action="game.php" method="post">
  44. <input name="submit" type="submit" value=" Proceed... "><?php
  45.  
  46. }
  47. else{
  48. echo"<i><h1>Sorry....</h1></i>";
  49. echo "<h2>The correct option is '$c_ans'</h2>";
  50. echo "<h2>Thank you...</h2>"
  51. ?><form action="score.php" method="post">
  52. <input name="submit" type="submit" value=" Proceed... "><?php
  53. }
  54. }
  55. }
  56. mysqli_close($conn);
  57. ?>
  58. </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement