SHARE
TWEET

login

a guest May 22nd, 2017 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. session_start();
  3. $out = "";
  4. if(isset($_SESSION["benutzername"])){
  5.   header("Location: index.php");
  6. }
  7.  
  8.  
  9.   if(isset($_POST["login"])){
  10.  
  11.     $servername = "localhost";
  12.     $user = "root";
  13.     $pwd = "root";
  14.     $db = "nera";
  15.  
  16.     $conn = mysqli_connect($servername, $user, $pwd, $db);
  17.  
  18.     $username = mysqli_real_escape_string($conn, $_POST["benutzername"]);
  19.     $password = md5(mysqli_real_escape_string($conn, $_POST["passwort"]));
  20.  
  21.     if(!$conn){
  22.       die("Connection failed:" . mysqli_connect_error());
  23.     }
  24.  
  25.     $sql = "SELECT IDBenutzer, Passwort FROM benutzer WHERE IDBenutzer = '$username' AND Passwort = '$password'";
  26.  
  27.     $result = mysqli_query($conn, $sql);
  28.  
  29.     if(!$result){
  30.       die("Dia Abfrage konn nicht ausgeführt werden:" . mysqli_error($conn));
  31.     }
  32.  
  33.     if(mysqli_num_rows($result) > 0){
  34.       $_SESSION["benutzername"] = $username;
  35.     if(isset($_POST["angemeldet_bleiben"]) /*|| isset($_COOKIE["benutzername"])*/){
  36.       setcookie("benutzername", $username, time()+60*60*24*3);
  37.     }
  38.       header('Location: index.php');
  39.     }   else{
  40.         $out = "<p>Benutzername oder Passwort ist falsch</p>";
  41.         $style = "class='error'";
  42.       }
  43.  
  44.     mysqli_close($conn);
  45.  
  46.   }
  47.  
  48. ?>
  49. <!DOCTYPE html>
  50. <html>
  51.   <head>
  52.     <meta charset="utf-8">
  53.     <title>NERA</title>
  54.     <link rel="stylesheet" type="text/css" href="style.css">
  55.   </head>
  56.   <body>
  57.     <h1>NERA</h1>
  58.     <h2>Willkommen bei NERA</h2>
  59.     <!--  JAVASCRIPT FORMULAR-->
  60.   <div class="login">
  61.     <form method="post">
  62.       <fieldset>
  63.         <legend><h3>Sie haben schon ein Konto? Jetzt anmelden!</h3></legend>
  64.         <input type="text" name="benutzername" autofocus placeholder="Benutzername" >
  65.         <input type="password" name="passwort" placeholder="Passwort">
  66.         <label><input type="checkbox" name="angemeldet_bleiben"><h3>Angemeldet bleiben</h3></label>
  67.         <input type="submit" name="login" value="Anmelden">
  68.       </fieldset>
  69.     </form>
  70.   </div>
  71.  
  72.   <div class="login2">
  73.     <form action="registrierung.php" onsubmit="registrierung()" method="post">
  74.       <fieldset>
  75.         <legend><h3>Neu bei NERA? Registriere dich jetzt!</h3></legend>
  76.         <input type="text" name="vorname" id="vorname" placeholder="Vorname" ><br>
  77.         <input type="text" name="nachname" id="nachname" placeholder="Nachname"><br>
  78.         <input type="text" name="benutzername" id="benutzername" placeholder="Benutzername"><br>
  79.         <input type="password" name="passwort" id="passwort" placeholder="Passwort"><br>
  80.         <input type="password" name="passwort2" id="passwort2" placeholder="Passwort wiederholen"><br>
  81.         <button type="submit" name="registrieren">Registrieren</button>
  82.       </fieldset>
  83.     </form>
  84.   </div>
  85.     <div id="ausgabe"></div>
  86.   </body>
  87. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top