-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathisset_and_empty.php
executable file
·87 lines (73 loc) · 1.98 KB
/
isset_and_empty.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
</head>
<body>
<form action="isset_and_empty.php" method="post">
<label for="">Enter your username: </label>
<input type="text" name="username">
<br><br>
<label for="">Enter your password: </label>
<input type="password" name="password">
<br>
<input type="submit" name="login" value="login" style="margin-left: 400px; padding: 20px 10px; position: absolute; top: 10px; ">
<br><br>
</form>
</body>
</html>
<?php
// isset() = Returns TRUE if a variable is declared and not null
// empty() = Returns TRUE if a variable is not declared, false, null, ""
// $username = "joey";
// echo isset($username);
// if(empty($user))
// {
// echo "<p style='color:red;padding-left: 100px;'>you must enter a username!</p>";
// }
// else
// {
// echo "<p style='color:blue; padding-left: 100px;'> {$user} </p>";
// }
// if (empty($username))
// {
// echo "this var is empty";
// }
// else if(isset($username))
// {
// echo "this var is set";
// }
// else
// {
// echo "this var is not set";
// }
// $username = $_POST["username"];
// $password = $_POST["password"];
// if (empty($username) || empty($password))
// {
// echo "Username or password cannot be empty.";
// }
foreach($_POST as $key => $value) {
echo "{$key} = {$value} <br>";
}
/*
if(isset($_POST["login"]))
{
$username = $_POST["username"];
$password = $_POST["password"];
if(empty($username))
{
echo "username is missing";
}
elseif(empty($password))
{
echo "password is missing";
}
else
{
echo "hello {$username}!";
}
} */
?>