Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once('_users.php');
- // Set connected flag to false
- $connected = false;
- $form_sent = false;
- // Check if POST data was send
- if(isset($_POST['username']) && isset($_POST['pass'])) {
- $form_sent = true;
- $username = $_POST['username'];
- $password = $_POST['pass'];
- // Check if username exists in db and if passwords match
- if(isset($users[$username]) && $users[$username] == $password) {
- // If password match, set flag to true
- $connected = true;
- }
- }
- ?>
- <pre style="padding:10px; background: #eee"><?php var_dump($_POST); ?></pre>
- <?php if(!$connected && $form_sent): ?>
- <p><b style="color:red">Wrong password or username</b></p>
- <?php endif; ?>
- <?php if($connected): ?>
- <div><b>You are connected</b></div>
- <?php endif; ?>
- <form method="POST">
- <input type="text" name="username" required/>
- <input type="password" name="pass" required/>
- <input type="submit" value="Validate"/>
- </form>
Add Comment
Please, Sign In to add comment