This most likely means the value of $stmt is false, as a result of a problem with your query causing the prepare to fail.
When you make an INSERT query, you must tell the database which coulmns you want to populate with the data.
Eg.
It should be bind_Param not bindParam.
Though I see now it’s mysqli you are using, not PDO. It’s such along time since I used mysqli, I don’t really rememer the syntax too well. I switched to PDO and never looked back, it’s way better.
Explicit parameter binding uses a reference to the variables, that is evaluated at the time of the execute() call. An unfortunate side effect of this is that there won’t be any php undefined variable/index errors if there’s a mistake in a variable/index name (yet another reason to use the PDO extension instead.)
As to finding out why the prepare() call failed. You ALWAYS need error handling for statements that can fail. For database statements, the easiest way of adding error handling for all the statements that can fail (connection, query, prepare, and execute), without adding logic at each statement, is to use exceptions for errors and in most cases let php catch the exception, where it will use its error related settings to control what happens with the actual error information (database statement errors will ‘automatically’ get displayed/logged the same as php errors.) The exception to this rule is when inserting/updating user submitted data and there’s a duplicate or out of range value. In this case, your code should catch the exception, detect if the sql error number is for something your code is designed to handle, then setup an error message for the visitor telling them what was wrong with the data that they submitted. For all other sql error numbers, just re-throw the exception and let php handle it. To enable exceptions for errors for the mysqli extension, add the following line of code before the point where you make the database connection, then remove any existing mysqli statement error handling logic since it will no longer be executed if there is an error -