I am using PHP to create a user in my database, but even though there are no False statements or Errors in the PHP code, no user is created (even though it prompts me signup=success). I think the problem is the Mysql part, maybe I defined the dates as the wrong datatype? (I tried both s and i in bind_param). How do I retrieve the error message on the Mysql part, if mysqli_stmt_execute doesn't succeed?
This is my code:
$insertsql = "INSERT INTO users (emailUsers, pwdUsers, f_name, l_name, istenant, date_created, date_modified) VALUES (?, ?, ?, ?, ?, ?, ?)";
$stmt = mysqli_stmt_init($mysqli);
if (!mysqli_stmt_prepare($stmt, $insertsql)) {
header("Location: ../signup.php?error=sqlerror");
exit();
} else {
$hashedpwd = password_hash($pwd, PASSWORD_DEFAULT);
mysqli_stmt_bind_param($stmt, 'sssssii', $mailid, $hashedpwd, $f_name, $l_name, $istenant, $date, $date);
mysqli_stmt_execute($stmt);
$display_block = printf("Error: %s.\n", mysqli_stmt_error($stmt));
header("Location: ../signup.php?signup=success");
exit();
}