test1
This commit is contained in:
parent
1a01adda9c
commit
0d99af0c57
|
|
@ -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.";
|
||||
}
|
||||
?>
|
||||
|
|
@ -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>
|
||||
Loading…
Reference in New Issue