Advertisement
Guest User

Untitled

a guest
Feb 19th, 2016
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.99 KB | None | 0 0
  1. <?php
  2.  include 'connect.php';
  3.  include 'functions.php';
  4.  
  5. if(isset($_POST['submit'])){
  6.     $message = array();
  7.     $username = mysqli_real_escape_string($con, $_POST['username']);
  8.     $password = md5(mysqli_real_escape_string($con, $_POST['password']));
  9.     if(empty($username) or empty($password)){
  10.        $message[] = "Message for empty user/pass";
  11.     }
  12.     else {
  13.         $check_login = mysqli_query($con, "SELECT id, user_level FROM korisnici WHERE username='".$username."' AND password='".$password."'");
  14.  
  15.  
  16.         if(mysqli_num_rows($check_login) == 1){
  17.             $run = mysqli_fetch_array($check_login);
  18.             $user_id = $run['id'];
  19.             $user_level = $run['user_level'];
  20.  
  21.             $_SESSION['user_id'] = $user_id;
  22.             header("Location: admin");
  23.             die;
  24.         }else{
  25.             $message[] = "Pogrešno Korisničko ime ili Lozinka!";
  26.         }
  27.     }
  28. }
  29. ?>
  30.  
  31.  
  32.  
  33. <html>
  34. <head>
  35.  
  36.  
  37.     <meta charset="UTF-8">
  38.     <meta name="viewport" content="width=device-width, minimumscale=1.0, maximum-scale=1.0" />
  39.     <title>Login - Admin</title>
  40.     <link rel='stylesheet' href='style.css' type='text/css' />
  41.     <?php include 'header.php'; ?>
  42. </head>
  43. <body >
  44. <div id="container_vanjski">
  45.     <div id="container">
  46.  
  47.         <form method="post">
  48.             <br/>
  49.             <?php if(sizeof($message)):?>
  50.                 <?php foreach($messages as $message):?>
  51.                     <p><?php echo $message?></p>
  52.                 <?php endforeach;?>
  53.  
  54.             <?php endif;?>
  55.             <br/>
  56.             <div id="log">
  57.  
  58.                 <label for="username">Korisničko ime:</label><input type="text" name="username" /><br />
  59.                 <label for="password">Lozinka:</label><input type="password" name="password" /><br />
  60.                 <br />
  61.                 <input type="submit" name="submit" value="Prijava" id="button" />
  62.  
  63.             </div>
  64.         </form>
  65.  
  66.     </div>
  67.  
  68.     <?php include 'footer.php'; ?>
  69. </div>
  70. </body>
  71. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement