Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'connect.php';
- include 'functions.php';
- if(isset($_POST['submit'])){
- $message = array();
- $username = mysqli_real_escape_string($con, $_POST['username']);
- $password = md5(mysqli_real_escape_string($con, $_POST['password']));
- if(empty($username) or empty($password)){
- $message[] = "Message for empty user/pass";
- }
- else {
- $check_login = mysqli_query($con, "SELECT id, user_level FROM korisnici WHERE username='".$username."' AND password='".$password."'");
- if(mysqli_num_rows($check_login) == 1){
- $run = mysqli_fetch_array($check_login);
- $user_id = $run['id'];
- $user_level = $run['user_level'];
- $_SESSION['user_id'] = $user_id;
- header("Location: admin");
- die;
- }else{
- $message[] = "Pogrešno Korisničko ime ili Lozinka!";
- }
- }
- }
- ?>
- <html>
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, minimumscale=1.0, maximum-scale=1.0" />
- <title>Login - Admin</title>
- <link rel='stylesheet' href='style.css' type='text/css' />
- <?php include 'header.php'; ?>
- </head>
- <body >
- <div id="container_vanjski">
- <div id="container">
- <form method="post">
- <br/>
- <?php if(sizeof($message)):?>
- <?php foreach($messages as $message):?>
- <p><?php echo $message?></p>
- <?php endforeach;?>
- <?php endif;?>
- <br/>
- <div id="log">
- <label for="username">Korisničko ime:</label><input type="text" name="username" /><br />
- <label for="password">Lozinka:</label><input type="password" name="password" /><br />
- <br />
- <input type="submit" name="submit" value="Prijava" id="button" />
- </div>
- </form>
- </div>
- <?php include 'footer.php'; ?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement