form validation for international characters

Discussions of secure PHP coding. Security in software is important, so don't be afraid to ask. And when answering: be anal. Nitpick. No security vulnerability is too small.

Moderator: General Moderators

Post Reply
Tolga
Forum Newbie
Posts: 1
Joined: Wed Oct 27, 2010 3:06 pm

form validation for international characters

Post by Tolga »

I am trying to build a form that validates input on the name field and I want to disallow certain characters such as commas, question marks, semicolon, star, backslash etc. I know I can use preg_match and set [a-zA-Z] but when I do that international characters are not allowed anymore. I tried something below but it gives error.

Code: Select all

if (preg_match("/[.\:\;\?\ ]/",$name)) { 
			 $hasError = true;
			 }
what should I do? is there any other function that I can use?

thanks in advance
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: form validation for international characters

Post by klevis miho »

Use php's sanitize and validate filters.
http://php.net/manual/en/filter.filters.sanitize.php
Post Reply