Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2021
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.22 KB | None | 0 0
  1. <?php
  2. include 'config.php';
  3. if (isset($_REQUEST['submit_Register']))
  4. {
  5.     if (empty($_REQUEST['username']))
  6.     {
  7.         die('Nezadal si jméno');
  8.     }
  9.     if (empty($_REQUEST['password']))
  10.     {
  11.         die('Nezadal si heslo');
  12.     }
  13.  
  14.     $username = $_REQUEST['username'];
  15.     $password = $_REQUEST['password'];
  16.     $username = mysqli_real_escape_string($conn, $username);
  17.     $password = mysqli_real_escape_string($conn, $password);
  18.     $kontrola = "SELECT * FROM login WHERE username = '$username'";
  19.     $vysledek = $conn->query($kontrola);
  20.     if ($vysledek->num_rows > 0)
  21.     {
  22.         while ($row = $vysledek->fetch_assoc())
  23.         {
  24.             die('Toto jméno jíž existuje');
  25.         }
  26.     }
  27.     else
  28.     {
  29.     }
  30.     $hash = password_hash($password, PASSWORD_BCRYPT);
  31.     $hash = mysqli_real_escape_string($conn, $hash);
  32.     $sql = "INSERT INTO login (username, heslo) VALUES ('$username', '$hash')";
  33.     $query = $conn->query($sql);
  34. }
  35. ?>
  36.  
  37.  
  38. <form action="register.php" method="post">
  39.  
  40. <input placeholder="Jméno" type="text" name="username"><br>
  41. <input placeholder="Heslo" type="password" name="password"><br>
  42. <button type="submit" name="submit_Register">Odeslat</button><br>
  43.  
  44.  
  45.  
  46. </form>
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement