We need to validate the data sent to the database so that it will be the correct,usefull and required by us and most important thing it will prevent spamming. To do the validation, and again using my example-please refer to the previous post, we could use the following steps:
1) Open
syarikat.php file located in
Models directory
2) Paste the following codes:

So, what do this code telling us-this question must be pop-up from your mind right now? Actually, this code validate the
S_Name (1. the company name) and
S_Email (2. the company email address) entered by users as shown below.

If users entered data that are not in accordance with the condition stated by us, the following errors will be generated.

There some other customizations that I have included in the code above. The first one is that I make my own error messages and secondly, in email field, where I have make a requirement that users need to enter a valid email and the users can also left it empty depends on the person choice. If I don't put the
allowEmpty in the code, users are forced to enter their email address even though they don't have any email addresses to proceed to the next steps.