0

Im trying to make a login system but im having this weird bug where everything goes right, no errors or anything but nothing is inserted into my database.

Here is my function to insert their data into the database, can anyone see anything wrong with this?

function createUser($conn, $username, $email, $password) {
  $sql = "INSERT INTO users (usersName, usersEmail, usersPwd) VALUES (?, ?, ?);";
  $stmt = mysqli_stmt_init($conn);
  if (!mysqli_stmt_prepare($stmt, $sql)) {
    header("location: ../register.php?error=stmtfailed");
    exit();
  }

  $hashedPassword = password_hash($pwd, PASSWORD_DEFAULT);

  mysqli_stmt_bind_param($stmt, "ssss", $username, $email, $hashedPassword);
  mysqli_stmt_execute($stmt);
  mysqli_stmt_close($stmt);
  header("location: ../register.php?error=none");
  exit();
}

I checked my database connection already and theres no problems there. Im at my witts end.

Nigel Ren
  • 56,122
  • 11
  • 43
  • 55
Bappo
  • 1

0 Answers0