SHARE
TWEET

PHP Login Index

PluzVS Mar 20th, 2016 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.    
  3.     session_start();
  4.    
  5.     if(!isset($_SESSION["id"]) || !isset($_SESSION["username"])){
  6.        
  7.     }else{
  8.         header("Location: painel.php");
  9.     }
  10.  
  11.  
  12.  
  13.     if(isset($_POST['login'])){
  14.         require("/data/config.inc.php");
  15.        
  16.         $username = strip_tags($_POST['username']);
  17.         $password = strip_tags($_POST['password']);
  18.        
  19.         $username = stripslashes($username);
  20.         $password = stripslashes($password);
  21.        
  22.         $username = mysqli_real_escape_string($db, $username);
  23.         $password = mysqli_real_escape_string($db, $password);
  24.        
  25.         $password = md5($password);
  26.        
  27.         $sql = "SELECT * FROM usuarios WHERE username = '$username' LIMIT 1";
  28.         $query = mysqli_query($db, $sql);
  29.         $row = mysqli_fetch_array($query);
  30.         $id = $row['id'];
  31.         $db_password = $row['password'];
  32.        
  33.         if($password = $db_password){
  34.             $_SESSION['username'] = $username;
  35.             $_SESSION['id'] = $id;
  36.             header("Location: painel.php");
  37.         }else{
  38.             echo 'Usuario ou senha incorretos';
  39.         }
  40.        
  41.     }
  42. ?>
  43.  
  44. <html>
  45.     <head>
  46.     <title> Login Pluz VS</title>
  47.     <meta charset="UTF-8">
  48.     </head>
  49.    
  50.     <body>
  51.         <form action="" method="post" enctype="multipart/form-data">
  52.             <input placeholder="Usuario" name="username" type="text">
  53.             <input placeholder="Senha" name="password" type="password">
  54.             <input value="Login" name="login" type="submit">
  55.        
  56.         </form>
  57.     </body>
  58.  
  59.  
  60. </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