19 lines
439 B
PHP
19 lines
439 B
PHP
<?php
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$students_json = file_get_contents('data/students.json');
|
|
$students = json_decode($students_json, true);
|
|
|
|
$new_student = [
|
|
'name' => $_POST['name'],
|
|
'email' => $_POST['email'],
|
|
];
|
|
|
|
$students[] = $new_student;
|
|
|
|
file_put_contents('data/students.json', json_encode($students, JSON_PRETTY_PRINT));
|
|
|
|
header('Location: students.php');
|
|
exit;
|
|
}
|
|
?>
|