-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthenticate.php
More file actions
34 lines (31 loc) · 1005 Bytes
/
authenticate.php
File metadata and controls
34 lines (31 loc) · 1005 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
<?php
/* This code also contains conditionals, which we already know. We are setting a variable to
know if we submitted a login or not, and set the cookies if so. But the highlighted lines
show you a new way of including conditionals with HTML. This makes the code more
readable when working with HTML code, avoiding the use of {}, and instead using : and
endif. Both syntaxes are correct, and you should use the one that you consider more
readable in each case. */
$submitted = isset($_POST['username']) && isset($_POST['password']);
if ( $submitted )
{
setcookie('username', $_POST['username'] );
}
?>
<!DOCTYPE html>
<html lang = "en">
<head>
<meta charset = "UTF-8">
<title>Bookstore</title>
</head>
<body>
<?php if( $submitted ) : ?>
<p>Your login info is</p>
<ul>
<li><b>username</b> : <?php echo $_POST['username']; ?></li>
<li><b>password</b> : <?php echo $_POST['password']; ?></li>
</ul>
<?php else: ?>
<p>You did not submit anything. </p>
<?php endif; ?>
</body>
</html>