Hi.
I've created the html form and a way to process data to mysql database, but what I want to do is handle errors. For example if user tried to register with invalid email format and username containing invalid characters, I want both to be shown once he tries to register. All I managed to do now is one error at a time (by doing if statements, starting from username via password to email. First it checks for valid username, then it checks for valid password, then it checks for valid email and returns one error at a time, depending of which error statement returned false so the script stops there)
I hope you can help me.
Showing errors at registration
Moderator: General Moderators
Re: Showing errors at registration
There are many ways of handling user errors. First of all, you can check anything that doesn't require server resources (such as a database) in Javascript before sending the form data to the server (you can even check the items that require server resources if you use Ajax). In fact, you should validate user inputs both in the browser (Javascript) and after your PHP script receives the data. Also, you don't have to return the error message to the server after checking each field. One way to do it is to create an array and add any error messages to the array until your checks are all done, then send any messages that may have been stored in the array, all at once.