This commit is contained in:
richonguzman 2023-09-15 17:56:39 -03:00
parent 1a01adda9c
commit 0d99af0c57
2 changed files with 38 additions and 0 deletions

19
data/process_form.php Normal file
View File

@ -0,0 +1,19 @@
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$data = [
'name' => $_POST['name'],
'email' => $_POST['email']
];
// Convert the data array to JSON format
$json_data = json_encode($data);
// Specify the path where you want to save the JSON file
$file_path = 'userdata.json';
// Save the JSON data to the file
file_put_contents($file_path, $json_data);
echo "Data saved as JSON successfully.";
}
?>

19
data/test1.html Normal file
View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<title>Save Form Data to JSON</title>
</head>
<body>
<h1>Save Form Data to JSON</h1>
<form method="POST" action="process_form.php">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br>
<input type="submit" value="Save as JSON">
</form>
</body>
</html>