D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
proc
/
thread-self
/
root
/
home
/
markniuj
/
bazmeasar.com
/
admin
/
Filename :
view.subscriber.php
back
Copy
<?php include "../config.php"; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Subscribers List</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> /* Apply your responsive CSS styles here */ table { width: 100%; border-collapse: collapse; } th, td { padding: 8px; text-align: left; border-bottom: 1px solid #ddd; } th { background-color: #f2f2f2; } .delete-btn { padding: 5px 10px; background-color: #dc3545; color: white; border: none; cursor: pointer; } </style> </head> <body> <header> <div class="logo"><a href='index.php'><img src="logo.png"></a></div> <!---menu start--> <div class="menu"></div> <!---menu end--> </header> <div class="container"> <h2>Subscribers List</h2> <table> <thead> <tr> <th>Email</th> <th>Name</th> <th>Phone</th> <th>Subscription Date</th> <th>Action</th> </tr> </thead> <tbody> <?php // Check if delete button is clicked and perform deletion if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['id'])) { $id_to_delete = $_POST['id']; $sql_delete = "DELETE FROM subscribers WHERE id = ?"; $stmt = $conn->prepare($sql_delete); $stmt->bind_param("i", $id_to_delete); if ($stmt->execute()) { echo "<p>Record deleted successfully</p>"; } else { echo "<p>Error deleting record: " . $stmt->error . "</p>"; } } // Fetch records from the subscribers table $sql = "SELECT * FROM subscribers ORDER BY id DESC"; $result = $conn->query($sql); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { echo "<tr>"; echo "<td>" . $row["email"] . "</td>"; echo "<td>" . $row["name"] . "</td>"; echo "<td>" . $row["phone"] . "</td>"; echo "<td>" . $row["subscription_date"] . "</td>"; echo "<td><form method='post'><input type='hidden' name='id' value='" . $row["id"] . "'><button class='delete-btn' type='submit'>Delete</button></form></td>"; echo "</tr>"; } } else { echo "<tr><td colspan='5'>No records found</td></tr>"; } // Close the database connection $conn->close(); ?> </tbody> </table> </div> </body> </html>