Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ob_start();
- ini_set('session.gc_maxlifetime', 3600);
- // each client should remember their session id for EXACTLY 1 hour
- session_set_cookie_params(3600);
- session_start();
- include 'bazadb.php';
- $error = false;
- if(isset($_POST['gumb_login'])){
- $ime= $_POST['ime'];
- $priimek= $_POST['priimek'];
- $username = $_POST['username'];
- $email = $_POST['email'];
- $password = $_POST['password'];
- $password2 = $_POST['password2'];
- if (empty($ime)) {
- $error = true;
- $imeError = "Please enter your full name.";
- }
- if (empty($priimek)) {
- $error = true;
- $priimekError = "Please enter your full lastname.";
- }
- if (empty($username)) {
- $error = true;
- $nameError = "Please enter your full username.";
- }
- if(strlen($username) < 3) {
- $error = true;
- $nameError = "Name must have atleat 3 characters.";
- }else{
- $query = "SELECT uporabnisko FROM uporabnik WHERE uporabnisko='$username'";
- $result = mysql_query($query);
- $count = mysql_num_rows($result);
- if($count!=0){
- $error = true;
- $nameError = "ime je že v uporabi.";
- }
- }
- //basic email validation
- if ( !filter_var($email,FILTER_VALIDATE_EMAIL) ) {
- $error = true;
- $emailError = "Vnesite pravilni email.";
- } else {
- // check email exist or not
- $query = "SELECT email FROM uporabnik WHERE email='$email'";
- $result = mysql_query($query);
- $count = mysql_num_rows($result);
- if($count!=0){
- $error = true;
- $emailError = "Email je že v uporabi.";
- }
- }
- // password validation
- if (empty($password)){
- $error = true;
- $passError = "Vpišite geslo.";
- } else if(strlen($password) < 5) {
- $error = true;
- $passError = "V geslu mora biti vsaj 5 črk.";
- }
- if($password != $password2){
- $error = true;
- $passError = "Vpisali ste dve različni gesli.";
- }
- $password = hash('sha256', $password);
- if( !$error ) {
- $query = "INSERT INTO uporabnik(ime,priimek,email,uporabnisko,geslo) VALUES('$ime','$priimek','$email','$username','$password')";
- $uspelo = mysql_query($query);
- echo $username;
- echo $password;
- if ($uspelo) {
- $errTyp = "success";
- $errMSG = "Registracija uspela!";
- unset($username);
- unset($email);
- unset($password);
- header("Location: index.php");
- } else {
- $errTyp = "danger";
- $errMSG = "¨Registracija ni uspela!";
- }
- }
- }
- ?>
- <!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="">
- <!-- 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>
- </ul>
- </div>
- <!-- /.navbar-collapse -->
- </div>
- <!-- /.container -->
- </nav>
- <div id="registracija" class="container content-section">
- <h1 class="text-center"> Registracija: </h1></br>
- <form method ="POST" action="">
- <h4> Vpišite ime: </h4><input type = "text"
- name = "ime" value="<?php echo $ime ?>"><br>
- <h4> Vpišite priimek: </h4><input type = "text"
- name = "priimek" value="<?php echo $priimek ?>"><br>
- <h4> Vpišite Uporabniško ime : </h4><input type = "text"
- name = "username" value="<?php echo $username ?>"></br>
- <h4> Vpišite email: </h4><input type = "email"
- name = "email" value="<?php echo $email ?>"><br>
- <h4> Vpišite geslo:</h4> <input type = "password"
- name = "password" value=""><br>
- <h4> Ponovno vpišite geslo:</h4> <input type = "password"
- name = "password2" value=""><br><br><br>
- <?php echo $nameError; ?>
- <?php echo $emailError; ?>
- <?php echo $passError; ?>
- <?php echo $imeError; ?>
- <?php echo $priimekError; ?>
- <button class="btn btn-default btn-" type = "submit"
- name = "gumb_login">Registracija</button>
- </form>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement