Guest User

Untitled

a guest
Dec 7th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.15 KB | None | 0 0
  1. <?php
  2. require 'Include/functions.php';
  3. head();
  4. nav();
  5. dbconn();
  6. ?>
  7. <h1 align="center">Login</h1>
  8. <p align="center">Füllen Sie das folgende Formular aus, um sich einloggen zu können.</p>
  9.  
  10. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  11.     <table align="center">
  12.    
  13.         <tr>
  14.             <td>Username</td>
  15.             <td><input type="text" name="username" size="30"></td>
  16.         </tr>
  17.        
  18.         <tr>
  19.             <td>Passwort</td>
  20.             <td><input type="password" name="password" value="" size="30" ></td>
  21.         </tr>
  22.    
  23.         <tr>
  24.             <td></td>
  25.             <td><input type="submit" name="login" value="Login!"></td>
  26.         </tr>
  27.        
  28.     </table>
  29. </form>
  30.  
  31. <?php
  32.  
  33.  
  34. if(isset($_COOKIE['ID_my_site'])) {
  35.     $usersname = $_COOKIE['ID_my_site'];
  36.     $pass = $_COOKIE['Key_my_site'];
  37.     $check = mysql_query('SELECT * FROM users WHERE username = \''.mysql_real_escape_string($usersname).'\'')or die(mysql_error());
  38.  
  39.     while($info = mysql_fetch_array( $check )) {
  40.         if ($pass == $info['passhash']) {
  41.             Header('Location: index.php');
  42.         }
  43.     }
  44. } else {
  45.  
  46. if (isset($_REQUEST['login'])) {
  47.     if(!isset($_REQUEST['username']) | !isset($_REQUEST['password'])) {
  48.         exit('Du hast vergessen ein Feld auszufüllen.');
  49.     }
  50.     if (!get_magic_quotes_gpc()) {
  51.         $_REQUEST['email'] = addslashes($_REQUEST['email']);
  52.     }
  53.    
  54.     $check = mysql_query("SELECT * FROM users WHERE username = '".$_REQUEST['username']."'")or die(mysql_error());
  55.     $check2 = mysql_num_rows($check);
  56.    
  57.     if ($check2 == 0) {
  58.         exit('Dieser users existiert nicht in unserer Datenbank. <a href=register.php><b><u>Zum registrieren hier klicken</u></b></a>');
  59.     }
  60.  
  61.     while($info = mysql_fetch_array( $check )) {
  62.         $_REQUEST['passhash'] = stripslashes($_REQUEST['passhash']);
  63.         $info['passhash'] = stripslashes($info['passhash']);
  64.         $_REQUEST['passhash'] = md5($_REQUEST['passhash']);
  65.        
  66.         if ($_REQUEST['passhash'] != $info['passhash']) {
  67.             exit('Falsches Passwort, bitte versuchen Sie es nochmal.');
  68.         } else {
  69.            
  70.             $_REQUEST['usersname'] = stripslashes($_REQUEST['usersname']);
  71.  
  72.             setcookie('ID_my_site', $_REQUEST['usersname'], time()+3600);
  73.             setcookie('Key_my_site', $_REQUEST['pass'], time()+3600);
  74.             Header('Location: index.php');
  75.         }
  76.     }
  77. }
  78. }
  79. ?>
Add Comment
Please, Sign In to add comment