php – a log in function keep on sending to the wrong url/page even tho i log in correctly

So i made a simple login system and my problem is that it keeps on sending me to login.php?error=wrongpassword and that means i entered the wrong password even tho i logged in the correct password and the correct username

my functions.inc.php codes look like this

function uidExists($conn, $username) {
   $sql = "SELECT * FROM highscore WHERE username = ?;";
   $stmt = mysqli_stmt_init($conn);
   if (!mysqli_stmt_prepare($stmt, $sql)) {
     header("location: signup.php?error=usernametaken");
     exit();
   }

   mysqli_stmt_bind_param($stmt, "s", $username);
   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 loginUser($conn, $username, $pwd) {
      $uidExists = uidExists($conn, $username );
    
      if ($uidExists === false) {
        header("location: login.php?error=wrongusername");
        exit();
      }
    
      $pwdHashed = $uidExists ("password");
      $checkPwd = password_verify($pwd, $pwdHashed);
    
      if ($checkPwd === false) {
        header("location: login.php?error=wrongpassword");
        exit();
      }
    
      else if ($checkPwd === true) {
        session_start();
        $_SESSION("userid") = $uidExists ("userid");
        $_SESSION("username") = $uidExists ("username");
        header("location: index2.php");
        exit();
      }

heres my login.php

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
</head>
<body>
  <h2>Log In</h2>
  <form action="login.inc.php" method="POST">
    <input type="text" name="username" placeholder="Username...">
    <input type="password" name="pwd" placeholder="Password...">
    <button type = "submit" name="submit">Sign Up</button>
  </form>

and heres my login.inc.php

<?php

if (isset($_POST("submit"))) {
    
    $username = $_POST("username");
    $pwd = $_POST("pwd");

  require_once 'dbh.inc.php';
  require_once 'functions.inc.php';

    if (emptyInputLogin($username, $pwd) !== false){
    header("location: login.php?error=emptyinput");
    exit();
  }

  loginUser($conn, $username, $pwd);
}

else {
    header("location: login.php");
    exit();
}

?>

This how my database looks like

 userid | username | password | score
    1   |    123   |    123   |   1
    2   |    312   |    312   |   3

I tried checking if I type the column name from the database wrong but no i typed it correctly.
I also tried making a new username and password and logged that in but still the same result.

Credits to the youtuber name Dani Krossing i got all this codes from him.