Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Home - Property Management Dashboard</title
- <meta charset="UTF 8"/>
- <h1>Property Management Dashboard</h1>
- </head>
- <body>
- <?php
- $db_address = 'localhost';
- $db_user = 'webauth';
- $db_pass = 'webauth';
- $db_name = 'properties';
- $db = new mysqli($db_address, $db_user, $db_pass, $db_name);
- if(mysqli_connect_errno()) {
- echo "Could not connect to the database. Please try again later.";
- exit;
- }
- //require('dbConnection.php');
- session_start();
- function createButtonColumn ($hiddenName, $hiddenValue,
- $buttonText, $actionPage){
- echo "<td>";
- echo "<form action=$actionPage method=\"POST\">";
- echo "<input type=\"hidden\" name=$hiddenName value=$hiddenValue>";
- echo "<input type=\"submit\" name=\"link\" value=$buttonText>";
- echo "</form>";
- echo "</td>";
- }
- $validLogin = require('checkLogin.php');
- $validSession = require('checkSession.php');
- if ($validLogin || $validSession) {
- $name = $_SESSION['valid_user'];
- echo "Welcome, $name<br>";
- echo '<table border = "1" cellpadding = "5">';
- echo "<tr>";
- echo "<th>Address</th>";
- echo "<th>Price</th>";
- echo "<th>Seller Name</th>";
- echo "<th>Seller Phone</th>";
- echo "<th></th>";
- echo "<th></th>";
- echo "</tr>";
- $query = "SELECT concat(address, ', ', suburb) AS addressSub, price, sellername, sellerphone, propertyid FROM property ORDER BY suburb";
- $result = $db->query($query);
- $num_results = $result->num_rows;
- for ($i = 0; $i < $num_results; $i++)
- {
- $row = $result->fetch_assoc();
- $propertyid = stripcslashes($row['propertyid']);
- $address = stripslashes($row['addressSub']);
- $price = stripslashes($row['price']);
- $name = stripslashes($row['sellername']);
- $phone = stripslashes($row['sellerphone']);
- echo "<tr>";
- echo "<td valign=\"top\">$address</td>";
- echo "<td valign=\"top\">$price</td>";
- echo "<td valign=\"top\">$name</td>";
- echo "<td valign=\"top\">$phone</td>";
- createButtonColumn("propertyid", $propertyid, "Edit", "edit.php");
- createButtonColumn("propertyid", $propertyid, "Delete", "delete.php");
- echo "</tr>";
- }
- $result->free();
- $db->close();
- echo "</table>";
- }
- else{
- $actionPage= "home.php";
- include('loginForm.php');
- }
- ?>
- <a href="home.php">Home</a> |
- <a href="add.php">Add New Property</a> |
- <a href="logout.php">Log Out</a>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement