How can PHP be used to create an admin page for dynamically changing the status of a website (online/offline)?

To create an admin page for dynamically changing the status of a website (online/offline), you can create a simple PHP script that updates a status variable in a configuration file. The admin page can have a form with radio buttons for selecting the status and a submit button to save the changes. The PHP script will read the submitted status value and update the configuration file accordingly.

<?php
// admin_page.php

// Check if form is submitted
if(isset($_POST['status'])) {
    // Update status in configuration file
    $status = $_POST['status'];
    file_put_contents('config.php', '<?php $website_status = "' . $status . '"; ?>');
    echo "Status updated successfully!";
}

// Display form for changing status
?>
<!DOCTYPE html>
<html>
<head>
    <title>Admin Page</title>
</head>
<body>
    <h1>Website Status</h1>
    <form method="post">
        <input type="radio" name="status" value="online" checked> Online<br>
        <input type="radio" name="status" value="offline"> Offline<br>
        <input type="submit" value="Save">
    </form>
</body>
</html>