Advertisement
Guest User

Untitled

a guest
May 29th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. <?php
  2. require '../scripts/database_connection.php';
  3.  
  4. $username = $_REQUEST['username'];
  5. $password = $_REQUEST['password'];
  6.  
  7. if (($username != "") && ($password != "")){
  8. $login_query = "SELECT * FROM student WHERE username= " . "'$username' AND password= " . "'$password'";
  9.  
  10. } else {
  11. die("<p>Username and password cannot be empty</p>");
  12. }
  13.  
  14. $result = mysql_query($login_query);
  15.  
  16. if (!$result){
  17. die("<p>Password and username is not correct" . mysql_error() . "</p>");
  18.  
  19. } else {
  20. $studentrow = mysql_fetch_array($result);
  21. $index = $studentrow['index_no'];
  22. }
  23.  
  24. ?>
  25.  
  26. <html>
  27. <head>
  28. <title>Results form</title>
  29. <link href="passpaper2014.css" rel="stylesheet" type="text/css" />
  30. </head>
  31. <body>
  32. <h2>Final Results</h2>
  33. <div id="tableContainer">
  34. <p>Name: <?php echo $studentrow['name'];?></p>
  35. <p>Index No: <?php echo $studentrow['index_no']; ?></p>
  36. <table class="table" border="1">
  37. <col width="250">
  38. <col width="80">
  39. <tr>
  40. <th>Subject</th>
  41. <th>Marks</th>
  42. </tr>
  43. <?php
  44. $retrive_query = "SELECT subject,marks FROM mark WHERE index_no= " . "'$index'";
  45. $marksresult = mysql_query($retrive_query);
  46. while ($row = mysql_fetch_array($marksresult)){
  47.  
  48. echo "
  49. <tr>
  50. <td>". $row['subject'] . "</td>
  51. <td>" . $row['marks'] . "</td>
  52. </tr>";
  53. }
  54.  
  55. ?>
  56. </table>
  57. </div>
  58. </body>
  59. </html>
  60.  
  61. $result = mysql_query($login_query);
  62. if (!$result){
  63. die("<p>Password and username is not correct" . mysql_error() . "</p>");
  64. }
  65.  
  66. $result = mysql_query($login_query);
  67. $studentrow = mysql_fetch_array($result);
  68. if (!$studentrow){
  69. die("<p>Password and username is not correct" . mysql_error() . "</p>");
  70. } else {
  71. $index = $studentrow['index_no'];
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement