jstudios
jstudios

Reputation: 856

PHP - Properly validate and/or sanitize form input

I have a form on a website for visitors to create an account. I need to make sure each field is in a certain format before saving it.

Username - only letters, numbers and underscore.

Password - Anything that's not harmful, how avoid php/html code?

Email - valid email (filter_var()?)

Mobile - 10 digit number (is_numeric()?)

Birthdate - needs to be YYYY-MM-DD, I'm using input type 'date'

Do I need to use Reg Ex to accomplish this?

Upvotes: 0

Views: 378

Answers (1)

ffab
ffab

Reputation: 11

You can also take a look at Php Filter / Validation or event Sanitization http://php.net/manual/en/book.filter.php

Upvotes: 1

Related Questions