Advertisement
Guest User

Untitled

a guest
Sep 10th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.72 KB | None | 0 0
  1. <html>
  2.     <head>
  3.         <title>Home - Property Management Dashboard</title
  4.         <meta charset="UTF 8"/>
  5.         <h1>Property Management Dashboard</h1>
  6.     </head>
  7.     <body>
  8.         <?php
  9.            
  10.             $db_address = 'localhost';
  11.     $db_user = 'webauth';
  12.     $db_pass = 'webauth';
  13.     $db_name = 'properties';
  14.    
  15.     $db = new mysqli($db_address, $db_user, $db_pass, $db_name);
  16.     if(mysqli_connect_errno()) {
  17.         echo "Could not connect to the database. Please try again later.";
  18.         exit;
  19.     }
  20.            
  21.             //require('dbConnection.php');
  22.             session_start();
  23.            
  24.            
  25.             function createButtonColumn ($hiddenName, $hiddenValue,
  26.                                          $buttonText, $actionPage){
  27.                                              
  28.                                              echo "<td>";
  29.                                              echo "<form action=$actionPage method=\"POST\">";
  30.                                              echo "<input type=\"hidden\" name=$hiddenName value=$hiddenValue>";
  31.                                              echo "<input type=\"submit\" name=\"link\" value=$buttonText>";
  32.                                              echo "</form>";           
  33.                                              echo "</td>";
  34.                                          }
  35.  
  36.        
  37.         $validLogin = require('checkLogin.php');
  38.         $validSession = require('checkSession.php');
  39.         if ($validLogin || $validSession) {
  40.                 $name = $_SESSION['valid_user'];
  41.                 echo "Welcome, $name<br>";
  42.        
  43.        
  44.        
  45.             echo '<table border = "1" cellpadding = "5">';
  46.             echo "<tr>";
  47.                 echo "<th>Address</th>";
  48.                 echo "<th>Price</th>";
  49.                 echo "<th>Seller Name</th>";
  50.                 echo "<th>Seller Phone</th>";
  51.                 echo "<th></th>";
  52.                 echo "<th></th>";
  53.             echo "</tr>";
  54.            
  55.              $query = "SELECT concat(address, ', ', suburb) AS addressSub, price, sellername, sellerphone, propertyid FROM property ORDER BY suburb";
  56.             $result = $db->query($query);
  57.             $num_results = $result->num_rows;
  58.            
  59.             for ($i = 0; $i < $num_results; $i++)
  60.             {
  61.                 $row = $result->fetch_assoc();
  62.                 $propertyid = stripcslashes($row['propertyid']);
  63.                 $address = stripslashes($row['addressSub']);
  64.                 $price = stripslashes($row['price']);
  65.                 $name = stripslashes($row['sellername']);
  66.                 $phone = stripslashes($row['sellerphone']);
  67.            
  68.            
  69.             echo "<tr>";
  70.             echo "<td valign=\"top\">$address</td>";
  71.             echo "<td valign=\"top\">$price</td>";
  72.             echo "<td valign=\"top\">$name</td>";
  73.             echo "<td valign=\"top\">$phone</td>";
  74.             createButtonColumn("propertyid", $propertyid, "Edit", "edit.php");
  75.             createButtonColumn("propertyid", $propertyid, "Delete", "delete.php");
  76.             echo "</tr>";
  77.             }
  78.             $result->free();
  79.             $db->close();
  80.        
  81.        
  82.            
  83.            
  84.        
  85.  
  86.  
  87.            
  88.                                              
  89.             echo "</table>";
  90.             }
  91.            
  92.             else{
  93.                 $actionPage= "home.php";
  94.                 include('loginForm.php');
  95.                
  96.             }
  97.        
  98.        
  99.        
  100.        
  101.        
  102.        
  103.        
  104.        
  105.                                    
  106.             ?>
  107.        
  108.        
  109.            
  110.            
  111.        
  112.  
  113.    
  114.     <a href="home.php">Home</a> |
  115.     <a href="add.php">Add New Property</a> |
  116.     <a href="logout.php">Log Out</a>
  117.    
  118.  
  119.     </body>
  120. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement