Gorilla3D Primative Teachings
Php Screencast Lession 07:
Keeping a User Logged in With Sessions
Code used in screencast
- <?php
-
- {
-
- if ($username == 'bob' and $password == '123')
- {
- $_SESSION['username'] = $username;
- echo 'Login Successful<br/>';
- }
- else
- {
- echo '<span style="color: red">Login Failed</span>';
- }
- }
- ?>
-
- <html>
- <head>
- <title>My login</title>
- </head>
- <body>
- <div></div>
- You are now logged in
- <?php } else { ?>
- <form action="" method="post">
- username: <input name="username" type="text" />
- password: <input name="password" type="password" />
- <input type="submit" />
- </form>
- <?php } ?>
- </body>
- </html>
-
