Answer the question
In order to leave comments, you need to log in
Why is Redirect not working properly?
Hello!
I write means registration, using a validator I check for the correctness of the entered data. And if something is wrong, a redirect should be used. The redirect works, but not like that. It should immediately redirect to the route, but I first have a white screen with the inscription "Redirected to: site.ru", and then it redirects to the desired page. How to fix it so that it immediately redirects to the desired page? Thanks in advance!
Controller :
$data = Input::all(); // Получаем все данные с полей
$dataSave = Input::flashExcept('password', 'password_repeat');
$rules = [
'login_users' => 'required|unique:users|min:4|max:30',
'mail_users' => 'required|unique:users|min:6|max:25',
'password' => 'required|',
'password_repeat' => 'required|',
'code_invites' => 'required|unique:invites|min:32|max:32'
];
if($validator->fails()){
// Если есть ошибки
return Redirect::route('register')->withErrors($validator)->withInput($dataSave);
}else{
// Если нет ошибок
}
Route::get('register', ['as' => 'register', 'uses' => '[email protected]']);
Route::post('register', ['as' => 'registerPost', 'uses' => '[email protected]', 'before' => 'csrf']);
Answer the question
In order to leave comments, you need to log in
Found this error again. It turns out that when you change the encoding of the file with the language, this error appears. It was fixed like this: created a new file and put everything from the previous one into a new file.
PS: I don't know what encoding was before, and what would happen when the encoding was restored, but my method works :)
1) "Redirected to: site.ru" - it is not clear where this is from. It's not laravel, it's the browser being naughty.
2) In L5, you don’t need to shove such a thing into the controller. For data validation, there is FromRequest which can, and most importantly, SHOULD be used for form validation.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question