Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <HTML>
- <HEAD>
- <TITLE> Cardiff bus members </TITLE>
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
- <?php
- require_once('include/config.php');
- require_once('include/core.php');
- require_once('include/bodyin.html');
- dbconn();
- //checks cookies to make sure they are logged in
- if(isset($_COOKIE['ID_my_site']))
- {
- $username = $_COOKIE['ID_my_site'];
- $pass = $_COOKIE['Key_my_site'];
- $check = mysql_query("SELECT * FROM signup WHERE username = '$username'")or die(mysql_error());
- while($info = mysql_fetch_assoc( $check ))
- {
- //if the cookie has the wrong password, they are taken to the login page
- if ($pass != $info['password'])
- { header("Location: login.php");
- }
- //otherwise they are shown the members area
- else
- {
- $db_host = 'localhost';
- $db_user = 'root';
- $db_pwd = 'joshua2006';
- $database = 'radio';
- $table = 'logs';
- if (!mysql_connect($db_host, $db_user, $db_pwd))
- die("Can't connect to database");
- if (!mysql_select_db($database))
- die("Can't select database");
- // sending query
- $result = mysql_query("SELECT * FROM {$table}");
- if (!$result) {
- die("Query to show fields from table failed");
- }
- $fields_num = mysql_num_fields($result);
- echo "<h1>cardiff bus logs</h1>";
- echo "<table border='1'><tr>";
- // printing table headers
- for($i=0; $i<$fields_num; $i++)
- {
- $field = mysql_fetch_field($result);
- echo "<td>{$field->name}</td>";
- }
- echo "</tr>\n";
- // printing table rows
- while($row = mysql_fetch_row($result))
- {
- echo "<tr>";
- // $row is array... foreach( .. ) puts every element
- // of $row to $cell variable
- foreach($row as $cell)
- echo "<td>$cell</td>";
- echo "</tr>\n";
- }
- mysql_free_result($result);
- }
- }
- }
- else
- //if the cookie does not exist, they are taken to the login screen
- {
- header("Location: login.php");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement