Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'config.php';
- if (isset($_REQUEST['submit_Register']))
- {
- if (empty($_REQUEST['username']))
- {
- die('Nezadal si jméno');
- }
- if (empty($_REQUEST['password']))
- {
- die('Nezadal si heslo');
- }
- $username = $_REQUEST['username'];
- $password = $_REQUEST['password'];
- $username = mysqli_real_escape_string($conn, $username);
- $password = mysqli_real_escape_string($conn, $password);
- $kontrola = "SELECT * FROM login WHERE username = '$username'";
- $vysledek = $conn->query($kontrola);
- if ($vysledek->num_rows > 0)
- {
- while ($row = $vysledek->fetch_assoc())
- {
- die('Toto jméno jíž existuje');
- }
- }
- else
- {
- }
- $hash = password_hash($password, PASSWORD_BCRYPT);
- $hash = mysqli_real_escape_string($conn, $hash);
- $sql = "INSERT INTO login (username, heslo) VALUES ('$username', '$hash')";
- $query = $conn->query($sql);
- }
- ?>
- <form action="register.php" method="post">
- <input placeholder="Jméno" type="text" name="username"><br>
- <input placeholder="Heslo" type="password" name="password"><br>
- <button type="submit" name="submit_Register">Odeslat</button><br>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement