I have been trying to make my login system for a while now but it keeps on failing to check the db or write to the db.
signup page:
<?php
  include_once 'header.php';
?>
<div class="header">
  <h2>Register</h2>
</div>
  
<form method="post" action="inc/signup.inc.php">
  <label>Full Name</label>
  <input type="text" name="name" placeholder="Full Name...">
  <label>Username</label>
  <input type="text" name="username" placeholder="Username">
  <label>Email</label>
  <input type="email" name="email" placeholder="Email">
  <label>Password</label>
  <input type="password" name="pwd">
  <label>Confirm password</label>
  <input type="password" name="pwdR">
  <button type="submit" name="submit">Sign Up</button>
<p>
  Already a member? <a href="login.php">Sign in</a>
</p>
</form>
<?php 
  include_once 'footer.php';
 ?>Signup backend page
<?php
if (isset($_POST["submit"])){
    $name = $_POST["name"];
    $username = $_POST["username"];
    $email = $_POST["email"];
    $pwd = $_POST["pwd"];
    $pwdr = $_POST["pwdR"];
    require_once 'db.inc.php';
    require_once 'func.inc.php';
    if (emptyInputSignup($name, $username, $email, $pwd, $pwdr) !== False) {
        header("location: ../signup.php?error=emptyinput");
        exit();
    }
    if (invaliduid($username) !== False) {
        header("location: ../signup.php?error=invaliduid");
        exit();
    }
    if (invalidEmail($email) !== False) {
        header("location: ../signup.php?error=invalidemail");
        exit();
    }
    if (pwdMatch($pwd, $pwdr) !== False) {
        header("location: ../signup.php?error=passwordsdontmatch");
        exit();
    }
    if (uidExists($conn, $username, $email) !== False) {
        header("location: ../signup.php?error=usernametaken");
        exit();
    }
    createUser($conn, $name, $username, $email, $pwd);
}
else{
    header("location: ../signup.php");
    exit();
}Now all the functions are handled on the following page where I think is where I went wrong.
<?php  
function emptyInputSignup($name, $username, $email, $pwd, $pwdr){
    $result;
    if (empty($name) || empty($username) || empty($email) || empty($pwd) || empty($pwdr)) {
        $result = true;
    }
    else{
        $result = false;
    }
    return $result;
}
function invaliduid($username){
    $result;
    if (!preg_match("/^[a-zA-Z0-9]*$/", $username)) {
        $result = true;
    }
    else{
        $result = false;
    }
    return $result;
}
function invalidEmail($email){
    $result;
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)){
        $result = true;
    }
    else{
        $result = false;
    }
    return $result;
}
function pwdMatch($pwd, $pwdr){
    $result;
    if ($pwd !== $pwdr){
        $result = true;
    }
    else{
        $result = false;
    }
    return $result;
}
function uidExists($conn, $username, $email){
    $sql = "SELECT * FROM users WHERE userUid = ? OR userEmail = ?;";
    $stmt = mysqli_stmt_init($conn);
    if (!mysqli_stmt_prepare($stmt, $sql)){
        header("location: ../signup.php?error=smtmfailedex");
        exit();
    }
    mysqli_stmt_bind_param($stmt, "ss" , $username, $email);
    mysqli_stmt_execute($stmt);
    $resultData = mysqli_stmt_get_result($stmt);
    if ($row = mysqli_fetch_assoc($resultData)) {
        return $row;
    }
    else{
        $result = false;
        return $result;
    }
    mysqli_stmt_close($stmt);
}
function createUser($conn, $name, $userid, $email, $pwd){
    $sql = "INSERT INTO users (userName, userUid, userEmail, userPwd) VALUES (?, ?, ?, ?);";
    $stmt = mysqli_stmt_init($conn);
    if (!mysqli_stmt_prepare($stmt, $sql)){
        header("location: ../signup.php?error=stmtfailedc");
        exit();
    }
    $hashedPwd = password_hash($pwd, PASSWORD_DEFAULT);
    mysqli_stmt_bind_param($stmt, "ssss" , $name, $username, $email, $hashedPwd);
    mysqli_stmt_execute($stmt);
    mysqli_stmt_close($stmt);
    header("location: ../profile.php?error=none");
    exit();
}Now the database link that I have made is on the following page: DB Link
<?php
$serverName = "localhost";
$dBUsername = "root";
$dBpassword = "";
$dBname = "sakidc";
$conn = mysqli_connect($serverName, $dBUsername, $dBpassword, $dBname);
if (!$conn){
    die("Connection Failed: " . mysqli_connect_error());
}