Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ob_start();
- session_start();
- include 'bazadb.php';
- // it will never let you open index(login) page if session is set
- $error = false;
- if( isset($_POST['gumb_login']) ) {
- // prevent sql injections/ clear user invalid inputs
- $username = trim($_POST['username']);
- $password = trim($_POST['password']);
- if(empty($password)){
- $error = true;
- $passError = "Vnesite vaše uporabniško ime in geslo.";
- }
- if(empty($username)){
- $error = true;
- $usernameError = "Vnesite vaše uporabniško ime in geslo.";
- }
- // if there's no error, continue to login
- if (!$error) {
- $password = hash('sha256', $password);
- $uspeh=mysql_query("SELECT id, uporabnisko, geslo FROM uporabnik WHERE uporabnisko='$username'");
- $row=mysql_fetch_array($uspeh);
- $count = mysql_num_rows($uspeh);
- if($count == 1 && $row['geslo']==$password) {
- $_SESSION['user'] = $row['id'];
- header("Location: index.php");
- } else {
- $errMSG = "Narobe vpisano uporabniško ime ali geslo.";
- }
- }
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Upster</title>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <meta name="description" content="">
- <meta name="author" content="">
- <link href="assets/css/iroks.css" rel="stylesheet">
- <link href="vendor/bootstrap/css/bootstrap.css" rel="stylesheet">
- <!-- Custom Fonts -->
- <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
- <link href="https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic" rel="stylesheet" type="text/css">
- <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
- <link href="assets/css/grayscale.min.css" rel="stylesheet">
- </head>
- <body id="page-top" data-spy="scroll" data-target=".navbar-fixed-top">
- <!-- Navigation -->
- <nav class="navbar navbar-custom navbar-fixed-top" role="navigation">
- <div class="container">
- <div class="navbar-header">
- <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-main-collapse">
- Menu <i class="fa fa-bars"></i>
- </button>
- <a class="navbar-brand page-scroll" href="index.php">
- <span class="light">Upster</span>
- </a>
- </div>
- <!-- Collect the nav links, forms, and other content for toggling -->
- <div class="collapse navbar-collapse navbar-right navbar-main-collapse">
- <ul class="nav navbar-nav">
- <!-- Hidden li included to remove active class from about link when scrolled up past about section -->
- <li class="hidden">
- <a href="#page-top"></a>
- </li>
- <li>
- <a class="page-scroll" href="prijava.php">PrijavaUserlogin...</a>
- </li>
- <li>
- <a class="page-scroll" href="logout.php">Odjavi</a>
- </li>
- </ul>
- </div>
- <!-- /.navbar-collapse -->
- </div>
- <!-- /.container -->
- </nav>
- <header class="intro">
- <div class="intro-body">
- <div class="container">
- <div class="row">
- <div id="prijava">
- <form method="POST" action="" id="form-prijava">
- <form
- action = "" method = "post">
- <h4> Vpišite uporabniško ime: </h4> <input type = "text"
- name = "username" placeholder = "username = MATIC"
- required autofocus>
- <h4> Vpišite geslo: </h4><input type = "password"
- name = "password" placeholder = "password = 1234" required><br><br>
- <button class="btn btn-outline btn-xl page-scroll" type = "submit"
- name = "gumb_login">Login</button>
- <?php echo $errMSG; ?>
- <h5> Nimate računa? <a href="registracija.php" >Registrirajte se.</a>
- </form>
- </form>
- </div>
- </div>
- </div>
- </div>
- </div>
- </header>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement