Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. <HTML>
  2. <HEAD>
  3. <TITLE> Cardiff bus members </TITLE>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
  5.  
  6. <?php
  7. require_once('include/config.php');
  8. require_once('include/core.php');
  9. require_once('include/bodyin.html');
  10. dbconn();
  11.  
  12.  
  13. //checks cookies to make sure they are logged in
  14. if(isset($_COOKIE['ID_my_site']))
  15. {
  16. $username = $_COOKIE['ID_my_site'];
  17. $pass = $_COOKIE['Key_my_site'];
  18. $check = mysql_query("SELECT * FROM signup WHERE username = '$username'")or die(mysql_error());
  19. while($info = mysql_fetch_assoc( $check ))
  20. {
  21.  
  22. //if the cookie has the wrong password, they are taken to the login page
  23. if ($pass != $info['password'])
  24. { header("Location: login.php");
  25. }
  26.  
  27. //otherwise they are shown the members area
  28. else
  29. {
  30.  
  31. $db_host = 'localhost';
  32. $db_user = 'root';
  33. $db_pwd = 'joshua2006';
  34.  
  35. $database = 'radio';
  36. $table = 'logs';
  37.  
  38. if (!mysql_connect($db_host, $db_user, $db_pwd))
  39. die("Can't connect to database");
  40.  
  41. if (!mysql_select_db($database))
  42. die("Can't select database");
  43.  
  44. // sending query
  45. $result = mysql_query("SELECT * FROM {$table}");
  46. if (!$result) {
  47. die("Query to show fields from table failed");
  48. }
  49.  
  50. $fields_num = mysql_num_fields($result);
  51.  
  52. echo "<h1>cardiff bus logs</h1>";
  53. echo "<table border='1'><tr>";
  54. // printing table headers
  55. for($i=0; $i<$fields_num; $i++)
  56. {
  57. $field = mysql_fetch_field($result);
  58. echo "<td>{$field->name}</td>";
  59. }
  60. echo "</tr>\n";
  61. // printing table rows
  62. while($row = mysql_fetch_row($result))
  63. {
  64. echo "<tr>";
  65.  
  66. // $row is array... foreach( .. ) puts every element
  67. // of $row to $cell variable
  68. foreach($row as $cell)
  69. echo "<td>$cell</td>";
  70.  
  71. echo "</tr>\n";
  72. }
  73. mysql_free_result($result);
  74.  
  75. }
  76. }
  77. }
  78. else
  79.  
  80. //if the cookie does not exist, they are taken to the login screen
  81. {
  82. header("Location: login.php");
  83. }
  84. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement