-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsession.php
More file actions
86 lines (73 loc) · 1.91 KB
/
Copy pathsession.php
File metadata and controls
86 lines (73 loc) · 1.91 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
session_start();
?>
<!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">
<style>
#sub input
{
width:100px;
height:25px;
margin-left:275px;
}
#fom
{
width:100%;
margin-left:300px;
margin-top:70px;
}
.ins
{
width:250px;
height:20px;
}
</style>
<title>Sessions in PHP</title>
</head>
<body>
<font color="grey">
<h1 align="center">Understanding $_SESSION in php</h1>
</font>
<div id="fom">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<label for="user">Enter Username:</label>
<input type="text" name="user" class="ins" placeholder="Enter your username">
<br><br>
<label for="pass">Enter Password:</label>
<input type="password" name="pass" class="ins" placeholder="*********"> <br><br>
<div id='sub'>
<input type="submit" value="login" name="submit">
</div>
</form>
</div>
<?php
if(isset($_POST['submit']))
{
$_SESSION['u']=$_POST['user'];
$_SESSION['p']=$_POST['pass'];
$user=$_SESSION['u'];
$pass=$_SESSION['p'];
if($user=="phpuser" && $pass=="php@123")
{
// res
$_SESSION['res']=true;
header("Location:second_session_page.php");
}
elseif ($user=="phpuser" && $pass!="php@123")
{
echo "ERROR! incorrect password";
echo "<br>";
echo "Please enter correct password";
}
else
{
echo "<script>alert('ERROR! invalid username as well as password');</script>";
}
}
?>
</body>
</html>