| Linux in-mum-web1499.main-hosting.eu 5.14.0-503.40.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Mon May 5 06:06:04 EDT 2025 x86_64 Path : /home/u901718425/domains/contentmgm.urbanpillar.in/public_html/ |
| Current File : /home/u901718425/domains/contentmgm.urbanpillar.in/public_html/index1.php |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Real Estate Project CRUD</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container mt-5">
<h2 class="mb-4">Real Estate Project Form</h2>
<!-- Form for Input -->
<form method="POST" action="" class="mb-4">
<div class="mb-3">
<label for="projectName" class="form-label">Project Name</label>
<input type="text" class="form-control" id="projectName" name="project_name" placeholder="Enter project name" required>
</div>
<div class="mb-3">
<label for="driveLink" class="form-label">Drive Link</label>
<input type="url" class="form-control" id="driveLink" name="drive_link" placeholder="Enter drive link" required>
</div>
<div class="mb-3">
<label for="price" class="form-label">Price</label>
<input type="number" class="form-control" id="price" name="price" placeholder="Enter price" required>
</div>
<div class="mb-3">
<label for="modifyDate" class="form-label">Date to Modify Price</label>
<input type="date" class="form-control" id="modifyDate" name="modify_date" required>
</div>
<button type="submit" class="btn btn-primary" name="save">Save</button>
</form>
<!-- Table for Displaying Records -->
<h3>Project Records</h3>
<table class="table table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Project Name</th>
<th>Drive Link</th>
<th>Price</th>
<th>Modify Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
// Database Connection
$conn = new mysqli("localhost", "u901718425_contentmgm", "Web.Developer@1", "u901718425_contentmgm");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Handle Save
if (isset($_POST['save'])) {
$project_name = $_POST['project_name'];
$drive_link = $_POST['drive_link'];
$price = $_POST['price'];
$modify_date = $_POST['modify_date'];
$sql = "INSERT INTO projects (project_name, drive_link, price, modify_date) VALUES ('$project_name', '$drive_link', '$price', '$modify_date')";
if ($conn->query($sql) === TRUE) {
echo "<div class='alert alert-success'>Record added successfully.</div>";
} else {
echo "<div class='alert alert-danger'>Error: " . $conn->error . "</div>";
}
}
// Handle Delete
if (isset($_GET['delete'])) {
$id = $_GET['delete'];
if ($conn->query("DELETE FROM projects WHERE id=$id") === TRUE) {
echo "<div class='alert alert-success'>Record deleted successfully.</div>";
} else {
echo "<div class='alert alert-danger'>Error: " . $conn->error . "</div>";
}
}
// Fetch Records
$result = $conn->query("SELECT * FROM projects");
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "<tr>
<td>" . $row['id'] . "</td>
<td>" . $row['project_name'] . "</td>
<td><a href='" . $row['drive_link'] . "' target='_blank'>Link</a></td>
<td>" . $row['price'] . "</td>
<td>" . $row['modify_date'] . "</td>
<td>
<a href='?edit=" . $row['id'] . "' class='btn btn-warning btn-sm'>Edit</a>
<a href='?delete=" . $row['id'] . "' class='btn btn-danger btn-sm'>Delete</a>
</td>
</tr>";
}
} else {
echo "<tr><td colspan='6' class='text-center'>No records found.</td></tr>";
}
?>
</tbody>
</table>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
<?php
// Create Database and Table if not exist
$conn->query("CREATE DATABASE IF NOT EXISTS u901718425_contentmgm");
$conn->query("USE u901718425_contentmgm");
$conn->query("CREATE TABLE IF NOT EXISTS projects (
id INT AUTO_INCREMENT PRIMARY KEY,
project_name VARCHAR(255) NOT NULL,
drive_link TEXT NOT NULL,
price FLOAT NOT NULL,
modify_date DATE NOT NULL
)");
?>