Good morning, I'm starting with laravel and I've created a login / registration system using Auth but I have a problem, I try to put the login and registration form on the same page and when I give "Logear" they send both the data of the first form as of the second.
When I leave the form blank and click on the "Enter" button, it shows me
The name field is required.
The password field is required.
The name field is required.
The password field is required.
{{ $errors->first('nombre') }}
{{ $errors->first('password') }}
{{ $errors->first('nombre') }}
{{ $errors->first('password') }}
<section class="wPanelUsuario" id="Login">
<h3>Bienvenido</h3>
<form action="{{ route('login') }}" method="POST">
{{ csrf_field() }}
<input type="text" name="nombre" placeholder="Usuario" value="{{ old('nombre') }}"/>
<input type="password" name="password" placeholder="Contraseña" value="{{ old('password') }}"/>
<input type="submit" class="botonPrimario" value="Entrar">
<a class="botonSecundario" id="suBoton">Registrarme</a>
</form>
</section>
<section class="wPanelUsuario none" id="Registro">
<h3>Ya casí...</h3>
<p class="text-center">¡Estás a un paso de obtener funciones exclusivas para usuarios registrados!</p>
<form action="{{ route('register') }}" method="POST">
{{ csrf_field() }}
<input type="text" name="nombre" placeholder="Usuario" value="{{ old('nombre') }}" required/>
<input type="email" name="email" placeholder="Correo electrónico" value="{{ old('email') }}" required/>
<input type="password" name="password" placeholder="Contraseña" value="{{ old('password') }}" required/>
<input type="password" name="password2" placeholder="Repite tu contraseña" value="{{ old('password2') }}" required/>
<input type="submit" class="botonPrimario" value="Registrarme">
<a class="botonSecundario" id="loginBoton">Iniciar sesión</a>
</form>
</section>
The problem is that I have two input called with the same name ("name", "password"). I tried to change the name of the input to one of the forms but the problem is that it automatically uses that name to insert the data in the data base and therefore I get an error too.
Controller:
protected function validator(array $data)
{
return Validator::make($data, [
'nombre' => 'required|string|unique:Usuarios',
'email' => 'required|string|email|unique:Usuarios',
'password' => 'required|string|min:6',
'password_confirmation' => 'required|string|min:6|same:password',
]);
}
protected function create(array $data)
{
return User::create([
'nombre' => $data['nombre'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
When I put email1 I already skipped the following error Column not found: 1054 Unknown column 'email1' in 'where clause' (SQL: select count (*) as aggregate from Usuarios
where email1
= example @ example. com)