<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$first_name = htmlspecialchars(trim($_POST['first_name']));
$last_name = htmlspecialchars(trim($_POST['last_name']));
$email = htmlspecialchars(trim($_POST['email']));
$data = "First Name: $first_name, Last Name: $last_name, Email: $email\n";
// Path to the text file where data will be stored
$file_path = "data.txt";
// Write the data to the text file
if (file_put_contents($file_path, $data, FILE_APPEND)) {
echo "Data submitted successfully!";
} else {
echo "Error writing to file!";
}
} else {
echo "Invalid request method.";
}
?>