real state

user type

<!DOCTYPE html>

<html>

<head>

    <title>Select User Type - Real Estate Management System</title>

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">

</head>

<body>

    <div class="container">

        <h1 class="mt-5">Welcome to the Real Estate Management System</h1>

        <div class="mt-4">

            <h2>Select User Type</h2>

            <?php

            // Check if the form has been submitted

            if ($_SERVER["REQUEST_METHOD"] == "POST") {

                $user_type = $_POST['user_type'];

                if ($user_type === 'buyer') {

                    // Redirect to the buyer page or perform any buyer-specific action

                    header('Location: buyer.php');

                    exit;

                } elseif ($user_type === 'seller') {

                    // Redirect to the seller page or perform any seller-specific action

                    header('Location: seller.php');

                    exit;

                }

            }

            ?>

            <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">

                <button type="submit" class="btn btn-primary" name="user_type" value="buyer">Buyer</button>

                <button type="submit" class="btn btn-success" name="user_type" value="seller">Seller</button>

            </form>

        </div>

    </div>

    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>

</body>

</html>




buyer

<!DOCTYPE html>

<html>

<head>

    <title>Buyer - Real Estate Management System</title>

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">

</head>

<body>

    <div class="container">

        <h1 class="mt-5">Welcome, Buyer!</h1>

        <div class="mt-4">

            <h2>Search Properties by Type</h2>

            <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">

                <div class="form-group">

                    <label for="property_type_search">Property Type:</label>

                    <input type="text" class="form-control" name="property_type_search" required>

                </div>

                <input type="submit" name="search_properties" value="Search" class="btn btn-primary">

            </form>

            <?php

            $servername = "localhost";

            $username = "root";

            $password = "";

            $dbname = "real";

            $conn = new mysqli($servername, $username, $password, $dbname);

            if ($conn->connect_error) {

                die("Connection failed: " . $conn->connect_error);

            }

            if (isset($_POST["search_properties"])) {

                $property_type_search = $_POST["property_type_search"];

                $sql = "SELECT * FROM properties WHERE property_type = '$property_type_search'";

                $result = $conn->query($sql);

                if ($result->num_rows > 0) {

                    echo "<div class='mt-4'>";

                    echo "<h2>Search Results</h2>";

                    echo "<table class='table'>";

                    echo "<thead><tr><th>Property Type</th><th>City</th><th>Area</th><th>Address</th><th>Sell/Rent</th><th>Amount</th><th>Property Features</th><th>Contact Number</th></tr></thead>";

                    echo "<tbody>";

                    while ($row = $result->fetch_assoc()) {

                        echo "<tr>";

                        echo "<td>" . $row["property_type"] . "</td>";

                        echo "<td>" . $row["city"] . "</td>";

                        echo "<td>" . $row["area"] . "</td>";

                        echo "<td>" . $row["address"] . "</td>";

                        echo "<td>" . $row["sell_or_rent"] . "</td>";

                        echo "<td>" . $row["amount"] . "</td>";

                        echo "<td>" . $row["property_features"] . "</td>";

                        echo "<td>" . $row["seller_contact_number"] . "</td>";

                        echo "</tr>";

                    }

                    echo "</tbody>";

                    echo "</table>";

                    echo "</div>";

                } else {

                    echo "<div class='alert alert-info mt-4'>No properties found with this property type.</div>";

                }

            }

            ?>

        </div>

    </div>

    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>

</body>

</html>



seller


<!DOCTYPE html>
<html>
<head>
    <title>Seller - Real Estate Management System</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
    <div class="container">
        <h1 class="mt-5">Welcome, Seller!</h1>
        <div class="mt-4">
            <h2>Add a New Property</h2>
            <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
                <div class="form-group">
                    <label for="property_type">Property Type:</label>
                    <input type="text" class="form-control" name="property_type" required>
                </div>

                <div class="form-group">
                    <label for="city">City:</label>
                    <input type="text" class="form-control" name="city" required>
                </div>

                <div class="form-group">
                    <label for="area">Area:</label>
                    <input type="text" class="form-control" name="area">
                </div>

                <div class="form-group">
                    <label for="address">Address:</label>
                    <input type="text" class="form-control" name="address" required>
                </div>

                <div class="form-group">
                    <label for="sell_or_rent">Sell or Rent:</label>
                    <select class="form-control" name="sell_or_rent">
                        <option value="Sell">Sell</option>
                        <option value="Rent">Rent</option>
                    </select>
                </div>

                <div class="form-group">
                    <label for="amount">Amount:</label>
                    <input type="number" class="form-control" name="amount" required>
                </div>

                <div class="form-group">
                    <label for="property_features">Property Features:</label>
                    <textarea class="form-control" name="property_features"></textarea>
                </div>

                <div class="form-group">
                    <label for="seller_contact_number">Seller Contact Number:</label>
                    <input type="text" class="form-control" name="seller_contact_number" required>
                </div>

                <input type="submit" name="add_property" value="Add Property" class="btn btn-primary mt-3">
            </form>
        </div>
        <?php
        $servername = "localhost";
        $username = "root";
        $password = "";
        $dbname = "real";
        $conn = new mysqli($servername, $username, $password, $dbname);
        if ($conn->connect_error) {
            die("Connection failed: " . $conn->connect_error);
        }
        if (isset($_POST["add_property"])) {
            $property_type = $_POST["property_type"];
            $city = $_POST["city"];
            $area = $_POST["area"];
            $address = $_POST["address"];
            $sell_or_rent = $_POST["sell_or_rent"];
            $amount = $_POST["amount"];
            $property_features = $_POST["property_features"];
            $seller_contact_number = $_POST["seller_contact_number"];

            $sql = "INSERT INTO properties (property_type, city, area, address, sell_or_rent, amount, property_features, seller_contact_number)
                    VALUES ('$property_type', '$city', '$area', '$address', '$sell_or_rent', '$amount', '$property_features', '$seller_contact_number')";

            if ($conn->query($sql) === TRUE) {
                echo "<div class='alert alert-success mt-3'>Property added successfully!</div>";
            } else {
                echo "<div class='alert alert-danger mt-3'>Error: " . $sql . "<br>" . $conn->error . "</div>";
            }
        }
        $sql = "SELECT * FROM properties";
        $result = $conn->query($sql);
        if ($result->num_rows > 0) {
            echo "<div class='mt-4'>";
            echo "<h2>All Properties</h2>";
            echo "<table class='table'>";
            echo "<thead><tr><th>Property Type</th><th>City</th><th>Area</th><th>Address</th><th>Sell/Rent</th><th>Amount</th><th>Property Features</th><th>Contact Number</th></tr></thead>";
            echo "<tbody>";
            while ($row = $result->fetch_assoc()) {
                echo "<tr>";
                echo "<td>" . $row["property_type"] . "</td>";
                echo "<td>" . $row["city"] . "</td>";
                echo "<td>" . $row["area"] . "</td>";
                echo "<td>" . $row["address"] . "</td>";
                echo "<td>" . $row["sell_or_rent"] . "</td>";
                echo "<td>" . $row["amount"] . "</td>";
                echo "<td>" . $row["property_features"] . "</td>";
                echo "<td>" . $row["seller_contact_number"] . "</td>";
                echo "</tr>";
            }
            echo "</tbody>";
            echo "</table>";
            echo "</div>";
        } else {
            echo "<div class='alert alert-info mt-4'>No properties found.</div>";
        }
        ?>
    </div>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>

Comments