this the php part
<?php
include 'assets/db.php';
if(isset($_POST["register"])){
$sql = "INSERT INTO table (name, email, user_name, pass)
VALUES ('".mysqli_real_escape_string($conn, $_POST["name"])."',
'".mysqli_real_escape_string($conn, $_POST["email"])."',
'".mysqli_real_escape_string($conn, $_POST["user_name"])."',
'".mysqli_real_escape_string($conn, $_POST["pass"])."')";
if ($conn->query($sql) === TRUE) {
echo "<script type='text/javascript'>window.top.location='_sign_in.php?l=1';</script>";
} else {
echo "<script type= 'text/javascript'>alert('Error! Please refresh the page and try again.');</script>";
}
$conn->close();
i am trying to avoid re-registration of any user_name, if user_name is already registered, redirect back to some page example- register.php?q=user_exists.