-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput.php
68 lines (56 loc) · 2.02 KB
/
input.php
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
session_start();
echo 'Request Method: ' . $_SERVER["REQUEST_METHOD"]; // Dit zou "POST" moeten zijn
var_dump($_POST);
$pagina = "input";
$title = "Form test"
?>
<!DOCTYPE html>
<html>
<?php include ("head.php")?>
<body>
<header>
<?php include ("header.php")?>
</header>
<?php
// define variables and set to empty values
$name = $email = $gender = $comment = $website = "";
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['name']) && isset($_POST['email'])) {
// Sla formuliergegevens op in de sessie
$_SESSION['name'] = $_POST['name'] ?? '';
$_SESSION['email'] = $_POST['email'] ?? '';
$_SESSION['comment'] = $_POST['comment'] ?? '';
$_SESSION['bla'] = $_POST['bla'] ?? '';
$name = test_input($_POST["name"]);
$email = test_input($_POST["email"]);
$website = test_input($_POST["website"]);
$comment = test_input($_POST["comment"]);
$gender = test_input($_POST["gender"]);
// Verwijs de gebruiker naar welcome.php
header('Location: welcome.php');
exit(); // Zorg ervoor dat de script verder stopt na de redirect
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<div class="inhoud">
<h1>Input</h1>
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>" method="POST">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
Bla:
<input type="radio" name="bla" value="1">1
<input type="radio" name="bla" value="2">2
<br>
<textarea name="comment" rows="5" cols="40"></textarea><br>
<input type="submit">
</form>
</div>
<footer>
<?php include ("footer.php")?>
</footer>
</html>