0

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?

4
  • stackoverflow.com/questions/129677/… Commented Nov 26, 2014 at 18:29
  • I already read that, I don't want to sanitize a username. It needs to be a certain format. For example, I couldn't have ef141%2wetw%2 as a username. Commented Nov 26, 2014 at 18:39
  • "Do I need to use Reg Ex to accomplish this?" No, you don't have to, but it would probably be the most efficient way Commented Nov 26, 2014 at 18:56
  • better go with regex then Commented Nov 27, 2014 at 4:16

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.