php – Laravel 7 old email input problems-ThrowExceptions

Exception or error:

I make a registration system with laravel. I tried various ways from google, but none of them work.

I want when I enter the wrong email format so that I get the message that it is wrong and that in value = “” it is all recorded.

My AccountController.php


namespace App\Http\Controllers;

use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Redirect;

class AccountController extends Controller
    public function getcreate(){
        return view('account.create');

    public function postcreate(){
        $validator = Validator::make(request()->all(), 
            'email'  =>      'required|max:50|email|unique:users',
            'username' =>    'required|max:20|min:3|unique:users',
            'password' =>    'required|min:6',
            'repeat_pass' => 'required|same:password'   

            return redirect()->route('account-create')->withErrors($validator)->withInput();


My create.blade.php

@extends ('layout.main')

@section ('content')

    <form action="{{ URL::route('account-create-post') }}" method="post">

            <div class="field">
                Email: <input type="text" name="email" placeholder="Email"{{ (old( 'email' )) ? ' value="'. e(old())  .'"' : ''    }}>
                        {{ $errors->first('email') }}
            <div class="field">
                Username: <input type="text" name="username" placeholder="Username">
                        {{ $errors->first('username') }}
            <div class="field">
                Password: <input type="password" name="password" placeholder="Passowrd">
                        {{ $errors->first('password') }}
            <div class="field">
                Repeat Password: <input type="password" name="repeat_pass" placeholder="Repeat Pssword">
                        {{ $errors->first('repeat_pass') }}

            <input type="submit" value="Create Account">

The ways from the internet I tried

value="{{ old('email') }}"
value="{{!! old('email') !!}}"
How to solve:

The old method will pull the previously flashed input data from the session, not to display error message.

To display an error message, you should use @error :

<div class="field">
    Email: <input type="text" name="email" placeholder="Email" value="{{ old('email') }}">

        <strong>{{ $message }}</strong>


you can display error message on the blade using this:

                                      @if (count($errors) > 0)
                                        <div class="alert alert-danger alert-dismissible" role="alert">
                                            <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span>
                                            @foreach ($errors->all() as $error)
                                            <p>{{ $error }}</p>

Leave a Reply

Your email address will not be published. Required fields are marked *