-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssociative array form.php
More file actions
35 lines (33 loc) · 897 Bytes
/
Associative array form.php
File metadata and controls
35 lines (33 loc) · 897 Bytes
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
<!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
<title>Document</title>
</head>
<body>
<form action=" index.php" method="post">
<label>username: </label>
<input type="text" name="username"><br>
<label>password: </label>
<input type="password" name="password"><br>
<input type="submit" name="1 '>
</form>
</body>
</html>
<?php
// isset() = Returns TRUE if a variable is declared and no
// empty() = Returns TRUE if a variable is not declared,
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}";
}
}
?>