Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php // Script 13.11 - index.php
- session_start(); // start session
- confirm_logged_in();
- function logged_in() {
- return isset($_SESSION['id']);
- }
- function confirm_logged_in() {
- if (!logged_in()) {
- redirect_to("login2.php");
- }
- }
- function redirect_to( $location = NULL ) {
- if ($location != NULL) {
- header("Location: {$location}");
- exit;
- }
- }
- /* This is the home page for this site. It displays:
- - The most recent quote (default)
- - OR, a random quote
- - OR, a random favorite quote */
- // Include the header:
- include('templates/header.html');
- // Need the database connection:
- include('../mysql_connect.php');
- // Define the query:
- $query = 'SELECT contact_id, name, company, phone, email, address FROM contactstable ORDER BY name ';
- // Run the query:
- if ($result = mysql_query($query, $dbc)) {
- while($row = mysql_fetch_array($result))
- {
- echo $row['name'];
- echo " " . $row['company'];
- echo " " . $row['phone'];
- echo " " . $row['email'];
- echo " " . $row['address'];
- echo "<br />";
- } // End of while loop.
- ?>
- <form action="index2.php" method="post"><input type="text" name="search"><input type="submit" value="Search"></form>
- <?php
- // If the admin is logged in, display admin links for this record:
- if (is_administrator()) {
- print "<p><b>Quote Admin:</b> <a href=\"edit_contact.php?id={$row['contact_id']}\">Edit</a> <->
- <a href=\"delete_entry.php?id={$row['contact_id']}\">Delete</a>
- </p>\n";
- }
- } else { // Query didn't run.
- print '<p class="error">Could not retrieve the data because:<br />' . mysql_error($dbc) . '.</p><p>The query being run was: ' . $query . '</p>';
- } // End of query IF.
- mysql_close($dbc); // Close the connection.
- include('templates/footer.html'); // Include the footer.
- ?>
Add Comment
Please, Sign In to add comment