-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsessions.php
More file actions
49 lines (49 loc) · 1.38 KB
/
sessions.php
File metadata and controls
49 lines (49 loc) · 1.38 KB
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
<?php
echo "Sessions in PHP<br>";
/*
session are stored in the server
so it can be used across multiple pages
*/
session_start();
if(isset($_POST['submit'])) {
$email = filter_input(INPUT_POST, 'email',
FILTER_SANITIZE_SPECIAL_CHARS);
$password = $_POST['password'];
if($email == 'hoang@gmail.com'
&& $password == '123456') {
$_SESSION['email'] = $email;
//redirect to another page
header('Location: ./dashboard.php');
} else {
echo "Incorrect email/password";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Login to your account</h1>
<form
action="<?php echo
htmlspecialchars($_SERVER['PHP_SELF']); ?>"
method="POST"
>
<h3>Login to your account</h3>
<div>
<label for="name">Email:</label>
<input type="text" name="email">
</div>
<div>
<label for="password">Password:</label>
<input type="password" name="password">
</div>
<input type="submit" value="Submit" name="submit">
</form>
</body>
</html>