Advertisement
Guest User

Untitled

a guest
Jan 7th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.64 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. ini_set('session.gc_maxlifetime', 3600);
  4.  
  5. // each client should remember their session id for EXACTLY 1 hour
  6. session_set_cookie_params(3600);
  7. session_start();
  8. include 'bazadb.php';
  9. $error = false;
  10.  
  11.  
  12. if(isset($_POST['gumb_login'])){
  13. $ime= $_POST['ime'];
  14. $priimek= $_POST['priimek'];
  15. $username = $_POST['username'];
  16. $email = $_POST['email'];
  17. $password = $_POST['password'];
  18. $password2 = $_POST['password2'];
  19.  
  20. if (empty($ime)) {
  21. $error = true;
  22. $imeError = "Please enter your full name.";
  23. }
  24. if (empty($priimek)) {
  25. $error = true;
  26. $priimekError = "Please enter your full lastname.";
  27. }
  28.  
  29. if (empty($username)) {
  30. $error = true;
  31. $nameError = "Please enter your full username.";
  32. }
  33.  
  34. if(strlen($username) < 3) {
  35. $error = true;
  36. $nameError = "Name must have atleat 3 characters.";
  37. }else{
  38. $query = "SELECT uporabnisko FROM uporabnik WHERE uporabnisko='$username'";
  39. $result = mysql_query($query);
  40. $count = mysql_num_rows($result);
  41. if($count!=0){
  42. $error = true;
  43. $nameError = "ime je že v uporabi.";
  44. }
  45. }
  46.  
  47. //basic email validation
  48. if ( !filter_var($email,FILTER_VALIDATE_EMAIL) ) {
  49. $error = true;
  50. $emailError = "Vnesite pravilni email.";
  51. } else {
  52. // check email exist or not
  53. $query = "SELECT email FROM uporabnik WHERE email='$email'";
  54. $result = mysql_query($query);
  55. $count = mysql_num_rows($result);
  56. if($count!=0){
  57. $error = true;
  58. $emailError = "Email je že v uporabi.";
  59. }
  60. }
  61. // password validation
  62. if (empty($password)){
  63. $error = true;
  64. $passError = "Vpišite geslo.";
  65. } else if(strlen($password) < 5) {
  66. $error = true;
  67. $passError = "V geslu mora biti vsaj 5 črk.";
  68. }
  69. if($password != $password2){
  70. $error = true;
  71. $passError = "Vpisali ste dve različni gesli.";
  72. }
  73. $password = hash('sha256', $password);
  74. if( !$error ) {
  75.  
  76. $query = "INSERT INTO uporabnik(ime,priimek,email,uporabnisko,geslo) VALUES('$ime','$priimek','$email','$username','$password')";
  77. $uspelo = mysql_query($query);
  78. echo $username;
  79. echo $password;
  80. if ($uspelo) {
  81. $errTyp = "success";
  82. $errMSG = "Registracija uspela!";
  83. unset($username);
  84. unset($email);
  85. unset($password);
  86. header("Location: index.php");
  87. } else {
  88. $errTyp = "danger";
  89. $errMSG = "¨Registracija ni uspela!";
  90. }
  91.  
  92.  
  93. }
  94. }
  95.  
  96. ?>
  97. <!DOCTYPE html>
  98. <html>
  99.  
  100. <head>
  101. <title>Upster</title>
  102. <meta charset="utf-8">
  103. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  104. <meta name="viewport" content="width=device-width, initial-scale=1">
  105. <meta name="description" content="">
  106. <meta name="author" content="">
  107.  
  108. <!-- Custom Fonts -->
  109. <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
  110. <link href="https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic" rel="stylesheet" type="text/css">
  111. <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
  112. <link href="assets/css/grayscale.min.css" rel="stylesheet">
  113.  
  114. </head>
  115.  
  116. <body id="page-top" data-spy="scroll" data-target=".navbar-fixed-top">
  117. <!-- Navigation -->
  118. <nav class="navbar navbar-custom navbar-fixed-top" role="navigation">
  119. <div class="container">
  120. <div class="navbar-header">
  121. <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-main-collapse">
  122. Menu <i class="fa fa-bars"></i>
  123. </button>
  124. <a class="navbar-brand page-scroll" href="index.php">
  125. <span class="light">Upster</span>
  126. </a>
  127. </div>
  128.  
  129. <!-- Collect the nav links, forms, and other content for toggling -->
  130. <div class="collapse navbar-collapse navbar-right navbar-main-collapse">
  131. <ul class="nav navbar-nav">
  132. <!-- Hidden li included to remove active class from about link when scrolled up past about section -->
  133. <li class="hidden">
  134. <a href="#page-top"></a>
  135. </li>
  136. </ul>
  137. </div>
  138. <!-- /.navbar-collapse -->
  139. </div>
  140. <!-- /.container -->
  141. </nav>
  142.  
  143. <div id="registracija" class="container content-section">
  144. <h1 class="text-center"> Registracija: </h1></br>
  145. <form method ="POST" action="">
  146. <h4> Vpišite ime: </h4><input type = "text"
  147. name = "ime" value="<?php echo $ime ?>"><br>
  148. <h4> Vpišite priimek: </h4><input type = "text"
  149. name = "priimek" value="<?php echo $priimek ?>"><br>
  150. <h4> Vpišite Uporabniško ime : </h4><input type = "text"
  151. name = "username" value="<?php echo $username ?>"></br>
  152. <h4> Vpišite email: </h4><input type = "email"
  153. name = "email" value="<?php echo $email ?>"><br>
  154. <h4> Vpišite geslo:</h4> <input type = "password"
  155. name = "password" value=""><br>
  156. <h4> Ponovno vpišite geslo:</h4> <input type = "password"
  157. name = "password2" value=""><br><br><br>
  158. <?php echo $nameError; ?>
  159. <?php echo $emailError; ?>
  160. <?php echo $passError; ?>
  161. <?php echo $imeError; ?>
  162. <?php echo $priimekError; ?>
  163. <button class="btn btn-default btn-" type = "submit"
  164. name = "gumb_login">Registracija</button>
  165.  
  166. </form>
  167. </div>
  168. </body>
  169. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement