Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php echo $error; ?>
- <form method="post" action="login.php">
- Username: <input type="text" name="username"> <br>
- Password: <input type="password" name="password"> <br>
- <input type="submit" value="Log In">
- </form>
- <?php
- function pc_validate($user,$pass) {
- /* replace with appropriate username and password checking,
- such as checking a database */
- $users = array('admin' => '1234567');
- if (isset($users[$user]) && ($users[$user] == $pass)) {
- return true;
- } else {
- return false;
- }
- }
- $secret_word = 'if i ate spinach';
- if (pc_validate($_REQUEST['username'],$_REQUEST['password'])) {
- setcookie('login',
- $_REQUEST['username'].','.md5($_REQUEST['username'].$secret_word));
- header('Location: site/index.php');
- }
- ?>
- <?php
- $secret_word = 'if i ate spinach';
- if (isset($_COOKIE['login'])) {
- list($c_username,$cookie_hash) = explode(',',$_COOKIE['login']);
- if (md5($c_username.$secret_word) == $cookie_hash) {
- $username = $c_username;
- } else {
- header('Location: extra/index.php');
- }
- } else {
- header('Location: extra/index.php');
- }
- ?>
- <?php
- include('session.php');
- ?>
- Hey Welcome! <?php echo $username; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement