Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. <?PHP
  2. include_once("connection.php");
  3. if(isset($_POST['txtUsername']) && isset($_POST['txtPassword']) && isset($_POST['txtAgain'])) {
  4.  
  5. $username = $_POST['txtUsername'];
  6. $password = $_POST['txtPassword'];
  7. $again = $_POST['txtAgain'];
  8.  
  9. $duplicates = "SELECT username FROM registracije WHERE username='$username'";
  10. $duplicate = mysqli_query($duplicates);
  11.  
  12. if (mysqli_num_rows($duplicate) > 0) {
  13. echo "username_exists";
  14. exit();
  15. } else {
  16. $insertRegistration = "INSERT INTO registracije (username, password)
  17. VALUES ('$username', '$password')";
  18.  
  19. $result = mysqli_query($conn, $insertRegistration);
  20.  
  21. if ($result) {
  22. echo "registration_successful";
  23. exit();
  24. }
  25. }
  26.  
  27. }
  28.  
  29. ?>
  30. <html>
  31. <head><title>Register</title></head>
  32. <body>
  33. <h1>Register</h1>
  34. <form action="<?PHP $_PHP_SELF ?>" method="POST">
  35. Username <input type="text" name="txtUsername" value="" /><br/>
  36. Password <input type="password" name="txtPassword" value="" /><br/>
  37. Password again<input type="password" name="txtAgain" value="" /><br/>
  38. <input type="submit" name="btnSubmit" value="Login"/>
  39. </form>
  40. </body>
  41. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement