-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform.php
46 lines (32 loc) · 1.02 KB
/
form.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
<?php
// echo 'Request method: ' . $_SERVER['REQUEST_METHOD'];
session_start();
if(!isset($_SESSION['count'])){
$_SESSION['count'] = 0;
} else {
$_SESSION['count']++;
}
echo $_SESSION['count'] . '<br>';
$form = '
<FORM action="form.php" method="post">
<fieldset>
<LABEL for="firstname">First name: </LABEL>
<INPUT type="text" name="firstname" id="firstname"><BR>
<LABEL for="lastname">Last name: </LABEL>
<INPUT type="text" name="lastname" id="lastname"><BR>
<LABEL for="email">email: </LABEL>
<INPUT type="text" name="email" id="email"><BR>
<INPUT type="radio" name="sex" value="Male"> Male<BR>
<INPUT type="radio" name="sex" value="Female"> Female<BR>
<INPUT type="submit" value="Send"> <INPUT type="reset">
</fieldset>
</FORM>';
if($_SERVER['REQUEST_METHOD'] == 'GET'){
echo $form;
} else {
echo 'thanks for your submission';
foreach($_POST as $key => $value) {
echo $key . ': ' . $value . '<br>';
}
}
?>