Advertisement
Guest User

PHP Login

a guest
Oct 26th, 2016
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.64 KB | None | 0 0
  1. <?php
  2.         $verbindung = mysql_connect("entfernt", "entfernt", "entfernt")
  3.         or die ("Fehler im System");
  4.         mysql_select_db("jericho") or die ("Verbindung zur Datenbank war nicht erfolgreich");
  5.  
  6.         session_start();
  7.         $output = 0;
  8.  
  9.  
  10.  
  11.         if(!isset($_SESSION["username"]) and !isset($_GET["page"]))  {
  12.         $output = 0;
  13.         }
  14.  
  15.         if($_GET["page"] == "log")  {
  16.  
  17.  
  18.         $user = strtolower($_POST["user"]);
  19.         $password = md5($_POST["password"]);
  20.  
  21.         $user_exist = ("SELECT * FROM userdaten WHERE Username = '".$user."' AND Passwort = '".$password."'");
  22.  
  23.         if($user_exist === true)  {
  24.         $_SESSION["username"] = $user;
  25.         $output = 1;
  26.         } else {
  27.         $output = 2;
  28.  
  29.     }
  30.     }
  31. ?>
  32.  
  33. <html>
  34.  <head>
  35.         <meta name='viewport' content='width=device-width, initial-scale=1' />
  36.         <meta charset="utf-8" />
  37.         <title>Login</title>
  38.     <?php
  39.         if($output === 1) {
  40.  
  41.     ?>
  42.         <meta http-equiv="refresh" content="3; URL=hash.php" />
  43.     <?php
  44.     }
  45.     ?>
  46.  </head>
  47.  <body>
  48.     <?php
  49.         if ($output === 0) {
  50.     ?>
  51.           Bitte logge dich ein: <br>
  52.           <form method="post"> action="?page=log"
  53.           Username: <input type="text" name="user"  /> <br>
  54.           Passwort: <input type="password" name="password"  /> <br>
  55.           <input type="submit" value="Einloggen"  /> <br>
  56.           Noch kein Account?  <a href='register.php'>Hier registrieren!</a>
  57.           </form>
  58.     <?php
  59.     }
  60.         if ($ouput === 1) {
  61.     ?>
  62.          Login erfolgreich! Du wirst sofort weiter geleitet
  63.     <?php
  64.     }
  65.         if ($output === 2) {
  66.     ?>
  67.          Passwort oder Username falsch, bitte probier es nochmal! <br>
  68.          <a href='index.php'>Zurück </a>
  69.     <?php
  70.     }
  71.     ?>
  72.  </body>
  73. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement