简体   繁体   中英

Is ther any alternatives for data validation of user input

Is preg_match() a reliable function to use it on its own to validate input data? just for validation(I am not talking about sanitizating and escaping).

For example: I want to allow only letters and numbers from a user input. To make sure that this happens i will use preg_match("/^[a-zA-Z0-9]*$/",$_POST["input"]) . apart from client side (js) and filter_input() (php) validation is there any other method to validate data?

thanks

EDIT: i meant very reliable method (the best ), I know that there other ways around to validate.

You should use filter_input or filter_var for validation. You can use range of pre-defined validation filters or specify your custom filter with filter callback .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM