Browser jokes: php Validation?
-
I'm basically testing the Google Chrome site, and I just noticed that Opera (the latest version) is a way to circumvent the COMBAT THREE to fill the age. It just ignores this field and even manages the shape and the clock.
http://site.ru/registration
Also, some old browsers might be able to repel people with non-resident sex, for example.
I mean. The opera here ignores and ignores
JS
andPHP
Validation. It's legal.PHP
and browser?Use the rules:
$rules[] = array( 'gender', 'required', 'message' => 'Укажите пол' ); $rules[] = array( 'birthYear', 'required', 'message' => 'Укажите год рождения' ); $rules[] = array('gender', 'in', 'range' => array("f", "m", "?"), 'message' => 'Укажите пол.');
Updating
Added to the rule:
$rules[] = array( 'birthYear', 'length', 'min'=>$AGE_START, 'max'=>$AGE_END, 'tooShort' => 'Укажите год рождения', 'tooLong' => 'Укажите год рождения', );
Opera stopped gluing.
-
You can get any data on your client's server. Data validation should always be on a server other than
JS
♪ If you have a registration without a compulsory field, then you're incorrect.PHP
code with validation.UPD
It's better not to turn to the mass.
$_POST
directly. Besides, there's nothing on your outgoing list. One browser sends it to you, the other's gone. It happens when you're in touch.$_POST['Form']['gender']
In one case, you have a line empty, in another case.null
(not a fact, that's my).Check.
$_POST
A range in the counteraller in different browsers:var_dump($_POST); die();
You could use a method. http://www.yiiframework.com/doc/api/1.1/CActiveRecord/#saveAttributes-detail or at a minimum check on the void:
if(isset($_POST['Form']['gender']) && $_POST['Form']['gender'] != '') { $form->gender = $_POST['Form']['gender']; }