-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrest.php
More file actions
28 lines (24 loc) · 759 Bytes
/
rest.php
File metadata and controls
28 lines (24 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
echo '
<form action="" method="post">
<input type="text" name="name" placeholder="Your Name" required>
<input type="email" name="email" placeholder="Your Email" required>
<input type="submit" value="Submit">
</form>
';
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Retrieve data from $_POST
$name = $_POST['name'];
$email = $_POST['email'];
setcookie('name', $name, time() + 3600);
setcookie('email', $email, time() + 3600);
// Store data in session
session_start();
$_SESSION['name'] = $name;
$_SESSION['email'] = $email;
// Redirect to another page
header('Location: welcome.php');
exit();
}