added input validation and prepared statement
modified error message printing
added function for validating number