How can fix the “Undefined variable $errors” in the Laravel 11 and CSRF token value is null.>

  Kiến thức lập trình
<div class="container">
    <div class="row">
        <div class="col-lg-12">
            <div class="content">
                <div class="content-header">
                    <h3>Laravel Auth</h3>
                </div>
                <div class="content-body">
                    <form action="{{route('customer.register.submit')}}" method="post" enctype="multipart/form-data">
                        @csrf
                        @if ($errors->any())
                            <div class="alert alert-danger">
                                <ul>
                                    @foreach ($errors->all() as $error)
                                        <li>{{ $error }}</li>
                                    @endforeach
                                </ul>
                            </div>
                        @endif
                        <div class="mb-3">
                            <label for="name" class="label"></label>
                            <input type="text" name="name" id="name" class="form-control">
                        </div>

                        <div class="mb-3">
                            <button type="submit" class="btn w-100">Regsiter</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

In the above form code I have use the “$errors” variable but I got the “Undefined variable $errors”.
And the token(CSRF) value is null. how can I fix it.

New contributor

AMIT GAUTAM is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT