File tree Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Original file line number Diff line number Diff line change 1
- <?
1
+ <?php
2
2
3
3
/*
4
4
Eng: Sessions are a way to store information ( in variables ) to be used across multiple pages . Unlike cookies , sessions are stored on the server.
8
8
9
9
//Sessions:
10
10
11
- if (isset ($ _POST ['submit ' ])) {
12
- //Eng: 1a option: || Pt: 1a opcao
13
- // $name = htmlspecialchars($_POST['name']);
14
- // $age = htmlspecialchars($_POST['age']);
15
-
16
- //Eng: 2a option: || Pt: 2a opcao
17
- $ name = filter_input (INPUT_POST , 'name ' , FILTER_SANITIZE_FULL_SPECIAL_CHARS );
18
- $ age = filter_input (INPUT_POST , 'age ' , FILTER_SANITIZE_FULL_SPECIAL_CHARS );
19
- echo $ name ;
20
- echo $ age ;
21
- }
11
+
12
+ if (isset ($ _POST ['submit ' ])){$ username = filter_input (INPUT_POST ,'username ' , FILTER_SANITIZE_SPECIAL_CHARS ) ; $ password = $ _POST ['password ' ];
13
+
14
+ if ($ username == 'john ' && $ password = 'password ' ) {
15
+ $ _SESSION ['username ' ] = $ username ; header ('Location : /php-crash/extras/dashboard.php ' );
16
+ } else {echo }
17
+
22
18
?>
23
19
24
20
<!--HTML-->
25
21
<!--Form-->
26
- <form action=" <? php echo $ _SERVER [ ' PHP_SELF ' ] ; ?> " method=" POST">
22
+ < form action = " < ? php echo htmlspecialchars ( $ _ SERVER [ ' PHP_SELF ' ] ) ; ? > " method = " POST " >
27
23
<div>
28
24
<label for="name">Name: </label><input type="text" name="name" required></input>
29
25
</div>
You can’t perform that action at this time.
0 commit comments