Can I sanatise user input like this?

Bes

Bes

Soldato
Joined
18 Oct 2002
Posts
7,318
Location
Melbourne
Hi,

I am using javascript to set a load of data client- side in some hidden text fields, which is then posted to PHP. I am trying to sanatise the input when it hits PHP using a ternary operator, but I cannot get this working.... In this example, if leftFSVal is not a double digit int, I go to the default value of 20 and continue processing.

PHP:
 $_POST['leftFsVal'] = ("/\d\d/") ? $_POST['leftFsVal'] : $_POST['leftFsVal']=20;

A) Is this a valid way to do it?
B) If so, what am I doing wrong?

Thanks
 
Back
Top Bottom