Advertisement
Guest User

Untitled

a guest
Jan 7th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.50 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. session_start();
  4. include 'bazadb.php';
  5.  
  6. // it will never let you open index(login) page if session is set
  7.  
  8.  
  9. $error = false;
  10.  
  11. if( isset($_POST['gumb_login']) ) {
  12.  
  13. // prevent sql injections/ clear user invalid inputs
  14. $username = trim($_POST['username']);
  15. $password = trim($_POST['password']);
  16.  
  17. if(empty($password)){
  18. $error = true;
  19. $passError = "Vnesite vaše uporabniško ime in geslo.";
  20. }
  21.  
  22. if(empty($username)){
  23. $error = true;
  24. $usernameError = "Vnesite vaše uporabniško ime in geslo.";
  25. }
  26.  
  27. // if there's no error, continue to login
  28. if (!$error) {
  29.  
  30. $password = hash('sha256', $password);
  31.  
  32. $uspeh=mysql_query("SELECT id, uporabnisko, geslo FROM uporabnik WHERE uporabnisko='$username'");
  33. $row=mysql_fetch_array($uspeh);
  34. $count = mysql_num_rows($uspeh);
  35.  
  36. if($count == 1 && $row['geslo']==$password) {
  37. $_SESSION['user'] = $row['id'];
  38. header("Location: index.php");
  39. } else {
  40. $errMSG = "Narobe vpisano uporabniško ime ali geslo.";
  41. }
  42.  
  43. }
  44.  
  45. }
  46. ?>
  47. <!DOCTYPE html>
  48. <html>
  49. <head>
  50. <title>Upster</title>
  51. <meta charset="utf-8">
  52. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  53. <meta name="viewport" content="width=device-width, initial-scale=1">
  54. <meta name="description" content="">
  55. <meta name="author" content="">
  56. <link href="assets/css/iroks.css" rel="stylesheet">
  57.  
  58. <link href="vendor/bootstrap/css/bootstrap.css" rel="stylesheet">
  59.  
  60. <!-- Custom Fonts -->
  61. <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
  62. <link href="https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic" rel="stylesheet" type="text/css">
  63. <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
  64. <link href="assets/css/grayscale.min.css" rel="stylesheet">
  65.  
  66.  
  67. </head>
  68. <body id="page-top" data-spy="scroll" data-target=".navbar-fixed-top">
  69. <!-- Navigation -->
  70. <nav class="navbar navbar-custom navbar-fixed-top" role="navigation">
  71. <div class="container">
  72. <div class="navbar-header">
  73. <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-main-collapse">
  74. Menu <i class="fa fa-bars"></i>
  75. </button>
  76. <a class="navbar-brand page-scroll" href="index.php">
  77. <span class="light">Upster</span>
  78. </a>
  79. </div>
  80.  
  81. <!-- Collect the nav links, forms, and other content for toggling -->
  82. <div class="collapse navbar-collapse navbar-right navbar-main-collapse">
  83. <ul class="nav navbar-nav">
  84. <!-- Hidden li included to remove active class from about link when scrolled up past about section -->
  85. <li class="hidden">
  86. <a href="#page-top"></a>
  87. </li>
  88. <li>
  89. <a class="page-scroll" href="prijava.php">PrijavaUserlogin...</a>
  90. </li>
  91. <li>
  92. <a class="page-scroll" href="logout.php">Odjavi</a>
  93. </li>
  94. </ul>
  95. </div>
  96. <!-- /.navbar-collapse -->
  97. </div>
  98. <!-- /.container -->
  99. </nav>
  100. <header class="intro">
  101. <div class="intro-body">
  102. <div class="container">
  103. <div class="row">
  104. <div id="prijava">
  105. <form method="POST" action="" id="form-prijava">
  106. <form
  107. action = "" method = "post">
  108. <h4> Vpišite uporabniško ime: </h4> <input type = "text"
  109. name = "username" placeholder = "username = MATIC"
  110. required autofocus>
  111. <h4> Vpišite geslo: </h4><input type = "password"
  112. name = "password" placeholder = "password = 1234" required><br><br>
  113. <button class="btn btn-outline btn-xl page-scroll" type = "submit"
  114. name = "gumb_login">Login</button>
  115. <?php echo $errMSG; ?>
  116. <h5> Nimate računa? <a href="registracija.php" >Registrirajte se.</a>
  117.  
  118. </form>
  119. </form>
  120. </div>
  121. </div>
  122. </div>
  123. </div>
  124. </div>
  125. </header>
  126.  
  127. </body>
  128. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement