I want that if user enter same email or username already in db or even if they enter one not in db it show an alert on the same page with all the content but it is taking them to a new page and there is no content there the URL is same BTW Php part query("SELECT * FROM Users WHERE user_email = '$useremail'"); $sqlTOCheckUsernameExists = $conn->query("SELECT * FROM Users WHERE user_name = '$username'"); if(!$sqlToCheckUserEmailExists || !$sqlTOCheckUsernameExists) { echo "SQL FAILED HERE IS WHY " . mysqli_error($conn); exit; } $doEmailExist = mysqli_num_rows($sqlToCheckUserEmailExists); $doUsernameExist = mysqli_num_rows($sqlTOCheckUsernameExists); if ($doEmailExist != 0) { $showError = "Email Is In Use"; echo ''; exit; } elseif($doUsernameExist != 0) { $showError = "Username Is In Use"; echo ''; exit; } else { $sqlToINsertUserIntoDatabase = $conn->query("INSERT INTO Users (sno, user_name, user_email, user_pass, user_date) VALUES(NULL, '$username', '$useremail', '$password', CURRENT_TIMESTAMP)"); if (!$sqlToINsertUserIntoDatabase) { echo "FAILED TO INSERT USER INTO DATABSE, HERE IS WHY" . mysqli_error($conn) . ""; } else { echo ''; exit; } } } ?>