Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'config.php';
- if(empty($_GET['a'])) $_GET['a'] = ' ';
- switch($_GET['a'])
- {
- case 'protected';
- if(USER_AUTHORIZED)
- {
- echo 'Welcome';
- }
- else
- {
- exit('Unauthorized!');
- }
- break;
- case 'login';
- if(!empty($_POST['username']) &&
- !empty($_POST['password']))
- {
- $username = $_POST['username'];
- $password = md5($_POST['password']);
- $result = $db->query("SELECT * FROM 'baftub_beta' WHERE 'username' = '".$username."' AND 'password' = '".$password."';");
- if($result->num_rows > 0)
- {
- $_SESSION['username'] = $username;
- $_SESSION['password'] = $password;
- echo 'Thanks you are now logged in!';
- header('Location: index.php?a=protected');
- }
- else echo 'Bad username/password.';
- }
- else
- {
- ?>
- <h1>Login</h1>
- <form method="post" action="">
- Username: <input type="text" name="username" /><br />
- Password: <input type="password" name="password" /><br />
- <input type="submit" value="Login" />
- </form>
- <?php
- }
- break;
- default:
- break;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement