-2

Just a stupid question: I know very well how to prevent MySQL Injection using PDO and MySQLi, but Can I prevent it if I just do not allow symbols in the forms?

I mean: If I use something like:

<input name="txt_user" id="txt_user" pattern="[a-zA-Z0-9-]+">

Can this prevent MySQL Injection?

Thanks in advance for your answers!!!

1 Answers1

2

No. There is nothing preventing the user from editing the HTML of the page and removing that attribute.

Validation should always be done on the server side. See also

Community
  • 1
  • 1
Andrei Savin
  • 2,350
  • 4
  • 26
  • 40
  • Thanks you Andrei, that's is a good reason, Obviously it is safer to validate on the server and for some reason, I had not noticed that detail, but thanks for refreshing my memory – Luis Gerardo Runge Nov 30 '16 at 01:17