Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $formLogin = '<form action="'.$_SERVER['PHP_SELF'].'?page=login" method="post">
- <label for="username">Username: </label>
- <input type="text" name="username" id="username" /><br />
- <label for="password">Password: </label>
- <input type="password" name="password" id="password" /><br />
- <input type="submit" name="login" value="Login" />
- </form>';
- if($_SESSION['ingelogd'] == false) {
- echo $formLogin;
- if(isset($_POST['login'])){
- if (!$_POST['username'] | !$_POST['password'] ) {
- die('You did not complete all of the required fields');
- }
- $username = strtolower($_POST['username']);
- $password = md5(strtolower($_POST['password']));
- $passwordCheck = md5(strtolower($_POST['passwordCheck']));
- // Check of de usernaam bestaat.
- $checkUser = mysql_query("SELECT username FROM users WHERE username = '".$username."'") or die(mysql_error());
- $checkUser2 = mysql_num_rows($checkUser);
- if ($checkUser2 == 0) {
- die('Sorry, the username '.$_POST['username'].' does not exist. Would you like to <a href="?page=register&username='.$username.'">Register it now</a>.');
- }
- $checkPassword = mysql_query("SELECT password FROM users WHERE username = '".$username."'") or die(mysql_error());
- $pwArray = mysql_fetch_array($checkPassword, MYSQL_ASSOC);
- if ($password == $pwArray['password']) {
- setcookie("username", $username);
- setcookie("password", $password);
- echo $_COOKIE['username'];
- echo '<br />';
- echo $_COOKIE['password'];
- echo '<br />';
- echo 'hardcoded '.$username.'';
- echo '<br />';
- echo 'hardcoded '.$password.'';
- $_SESSION['ingelogd'] = true;
- $ref = $_SERVER['HTTP_REFERER'];
- echo '<meta http-equiv="refresh" content="3;URL='.$ref.'">';
- echo 'Hello World!';
- //die('Your password does not match with the username '.$username.'.');
- } else {
- echo 'DIE World!';
- }
- /*echo '<pre>';
- echo print_r($_POST);
- echo '</pre>';*/
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement