So, i have 2 forms, one is for sign up, and another is for sign in
<div class="row">
<div class="col-md-6">
<h3>Sign Up</h3>
<form action="{{ route('signup') }}" method="post">
<div class="form-group">
<label for="email">Your E-Mail</label>
<input class="form-control" type="email" name="su_email" id="email">
</div>
<div class="form-group">
<label for="first_name">First Name</label>
<input class="form-control" type="text" name="first_name" id="first_name">
</div>
<div class="form-group">
<label for="password">Password</label>
<input class="form-control" type="password" name="su_password" id="password">
</div>
{{ csrf_field() }}
<button class="btn btn-primary">Submit</button>
</form>
</div>
<div class="col-md-6">
<h3>Sign In</h3>
<form action="{{ route('signin') }}" method="post">
<div class="form-group">
<label for="email">Your E-Mail</label>
<input class="form-control" type="email" name="si_email" id="email">
</div>
<div class="form-group">
<label for="password">Password</label>
<input class="form-control" type="password" name="si_password" id="password">
</div>
{{ csrf_field() }}
<button class="btn btn-primary">Submit</button>
</form>
</div>
Here is my controller
public function postSignUp(Request $request)
{
$email = $request['su_email'];
$first_name = $request['first_name'];
$password = bcrypt($request['su_password']);
$user = new User();
$user->email = $email;
$user->first_name = $first_name;
$user->password = $password;
$user->save();
return redirect()->back();
}
public function postSignIn(Request $request)
{
if (Auth::attempt(['email' => $request['si_email'], 'password' => $request['si_password']])) {
return view('dashboard');
}
return redirect()->back();
}
So the problem is: when i enter values in "sign in" form, and then go back to page, in my "first_name" field i have "si_email" value, and in "su_password" i have "si_password" value
Why this happens? I didnt set any value in my html.
redirect()->back()->withInput()? This should keep the original input in case of failed validation.