Guest User

Untitled

a guest
Nov 28th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Title</title>
  5. <link rel="stylesheet" href="notyf/notyf.min.css">
  6. </head>
  7. <body>
  8. <form action="" method="POST">
  9. <input type="text" name="user"/>
  10. <input type="text" name="pass"/>
  11. <button type="submit" onclick="myFunc()" name="submit">Register</button>
  12. </form>
  13.  
  14. <?php
  15. if (isset($_POST["submit"])) {
  16. if (!empty($_POST["user"]) && !empty($_POST["pass"])) {
  17. $user = $_POST["user"];
  18. $pass = $_POST["pass"];
  19. $conn = new mysqli("localhost", "root", "") or die (mysqli_error());
  20. $db = mysqli_select_db($conn, "toast") or die ("DB Error!");
  21. $query = mysqli_query($conn, "SELECT * FROM user WHERE user='".$user."'");
  22. $numrows = mysqli_num_rows($query);
  23. if ($numrows == 0) {
  24. $sql = "INSERT INTO user(user, pass) VALUES('$user', '$pass')";
  25. $result = mysqli_query($conn, $sql);
  26. if ($result) {
  27. echo "<script src='notyf/notyf.min.js'></script>";
  28. echo "<script>";
  29. echo "function myFunc() {";
  30. echo "var notyf = new Notyf();";
  31. echo "notyf.confirm('Success!');";
  32. echo "}";
  33. echo "</script>";
  34. } else {
  35. echo "Failure!";
  36. }
  37. } else {
  38. echo "Already exist! Please try again.";
  39. }
  40. }
  41. }
  42. ?>
  43. </body>
  44. </html>
Add Comment
Please, Sign In to add comment