Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Title</title>
- <link rel="stylesheet" href="notyf/notyf.min.css">
- </head>
- <body>
- <form action="" method="POST">
- <input type="text" name="user"/>
- <input type="text" name="pass"/>
- <button type="submit" onclick="myFunc()" name="submit">Register</button>
- </form>
- <?php
- if (isset($_POST["submit"])) {
- if (!empty($_POST["user"]) && !empty($_POST["pass"])) {
- $user = $_POST["user"];
- $pass = $_POST["pass"];
- $conn = new mysqli("localhost", "root", "") or die (mysqli_error());
- $db = mysqli_select_db($conn, "toast") or die ("DB Error!");
- $query = mysqli_query($conn, "SELECT * FROM user WHERE user='".$user."'");
- $numrows = mysqli_num_rows($query);
- if ($numrows == 0) {
- $sql = "INSERT INTO user(user, pass) VALUES('$user', '$pass')";
- $result = mysqli_query($conn, $sql);
- if ($result) {
- echo "<script src='notyf/notyf.min.js'></script>";
- echo "<script>";
- echo "function myFunc() {";
- echo "var notyf = new Notyf();";
- echo "notyf.confirm('Success!');";
- echo "}";
- echo "</script>";
- } else {
- echo "Failure!";
- }
- } else {
- echo "Already exist! Please try again.";
- }
- }
- }
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment