<?php
include('includes/header.php');
session_name("user-profile-session");
session_start();
error_reporting(E_ALL);
//start
$name = isset($_SESSION['name']) ? $_SESSION['name'] : '';
$email = isset($_SESSION['email']) ? $_SESSION['email'] : '';
$color = isset($_SESSION['color']) ? $_SESSION['color'] : '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Update session variables with form data
$_SESSION['name'] = $_POST['name'];
$_SESSION['email'] = $_POST['email'];
$_SESSION['color'] = $_POST['color'];
}
?>
<h1>User Profile</h1>
<form method="post" action="">
<label for="name">Name: </label>
<input type="text" id="name" name="name" value="<?php echo $name; ?>"><br><br>
<label for="email">Email: </label>
<input type="email" id="email" name="email" value="<?php echo $email; ?>"><br><br>
<label for="color">Favorite Color: </label>
<input type="text" id="color" name="color" value="<?php echo $color; ?>"><br><br>
<input type="submit" value="Save">
</form>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
echo "<h2>Saved Data:</h2>";
echo "Name: " . $_SESSION['name'] . "<br>";
echo "Email: " . $_SESSION['email'] . "<br>";
echo "Favorite Color: " . $_SESSION['color'] . "<br>";
}
include('includes/footer.php');
?>