I am pretty new to Laravel and I have this strange behavior with form input validation.
The strangest thing is that yesterday this code worked fine and today it stopped working and I can't explain why.
I have these validation rules in a controller method that handle the form submission:
$data = Input::all();
Log::info('INSERTED DATA: '.implode("|", $data));
// Regole di validazione sintattica del contenuto del form di registrazione:
$rules = array(
'name' => 'required',
'surname' => 'required',
'login' => 'required|unique:pm_user,login',
'email' => 'required|email|confirmed|unique:pm_user,email',
//'email_confirmation' => 'required|email|confirmed',
'pass' => 'required|required|min:6',
//'passConfirm' => 'required',
'g-recaptcha-response' => 'required|captcha',
);
// Validazione sintattica del form di registrazione:
$validator = Validator::make($data, $rules);
/*
* Se il form di registrazione contiene dati sintatticamente errati, ritorna alla pagina di registrazione
* passando la lista dei messaggi di errore da visualizzare
*/
if ($validator->fails()){
return Redirect::to('/registration')->withInput()->withErrors($validator);
}
// Altrimenti se i dati inseriti sono sintatticamente corretti:
else {
$token = md5(uniqid($data['email'], true));
...............................................................
...............................................................
DO SOMETHING AND WRITE THE DATA INTO THE pm_user TABLE
...............................................................
...............................................................
}
As you can see the $rules array contains these 2 specific rules:
'login' => 'required|unique:pm_user,login',
'email' => 'required|email|confirmed|unique:pm_user,email',
that perform the checks if in the pm_user table exist yet a record having the same login and email fields values. If exist a record having or the same login value or the same email value give an error.
Untill yesterdy it works fine. Now this behavior stops to work. Infact if I insert in the form a new user with the same username (login field) or\and the same email it give no error and enter in the else and inser the user in the table.
All the other validation rules works fine.
How is it possible? What can be happen? How can I try to fix this issue?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire