I see some php course then I learn mostly by practical way so my question is very newbie , I didn't understand why this code don't work solution for duplicate username while registre , and every time i receive probleme with header
function signup($conn) {
    $uid = $_POST['uid'];
    $pwd = $_POST['pwd'];
    if (isset($_POST['signupSubmit'])) {
        $query = mysql_query("select * from user where uid='$uid'");
        $encrypted_password = password_hash($pwd, PASSWORD_DEFAULT);
        if(mysql_num_rows(query)>0)
        {
             echo "<script> window.location.replace('test.php') </script>" ;
        }
        else {
        $sql = "insert into usi (uid, pwd)  values('$uid','$encrypted_password')";
        $result = $conn->query($sql);
        header("Location: test.php");
    }
}
}
 
    