Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel 7旧电子邮件输入问题_Php_Laravel - Fatal编程技术网

Php Laravel 7旧电子邮件输入问题

Php Laravel 7旧电子邮件输入问题,php,laravel,Php,Laravel,我和拉威尔建立了一个注册系统。我试过谷歌的各种方法,但都不管用 我希望当我输入错误的电子邮件格式时,我会收到错误的消息,并且在value=“”中,所有内容都被记录下来 My AccountController.php <?php namespace App\Http\Controllers; use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Redirect; class Account

我和拉威尔建立了一个注册系统。我试过谷歌的各种方法,但都不管用

我希望当我输入错误的电子邮件格式时,我会收到错误的消息,并且在value=“”中,所有内容都被记录下来

My AccountController.php

<?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(), 
        array(
            'email'  =>      'required|max:50|email|unique:users',
            'username' =>    'required|max:20|min:3|unique:users',
            'password' =>    'required|min:6',
            'repeat_pass' => 'required|same:password'   
        ));

        if($validator->fails()){
            return redirect()->route('account-create')->withErrors($validator)->withInput();
        }
        else{

        }
    }
}

@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())  .'"' : ''    }}>
                @if($errors->has('email'))
                        {{ $errors->first('email') }}
                @endif
            </div>
            <div class="field">
                Username: <input type="text" name="username" placeholder="Username">
                @if($errors->has('uesrname'))
                        {{ $errors->first('username') }}
                @endif
            </div>
            <div class="field">
                Password: <input type="password" name="password" placeholder="Passowrd">
                @if($errors->has('password'))
                        {{ $errors->first('password') }}
                @endif
            </div>
            <div class="field">
                Repeat Password: <input type="password" name="repeat_pass" placeholder="Repeat Pssword">
                @if($errors->has('repeat_pass'))
                        {{ $errors->first('repeat_pass') }}
                @endif
            </div>


            <input type="submit" value="Create Account">
            @csrf
    </form>
@stop 

old
方法将从会话中提取先前闪烁的输入数据,而不显示错误消息

要显示错误消息,应使用
@error

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

    @error('email')
        <strong>{{ $message }}</strong>
    @enderror
</div>

电邮:
@错误('电子邮件')
{{$message}}
@恩德罗

您可以使用以下命令在刀片上显示错误消息:

                                      @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>
                                            </button>
                                            <strong>Error!</strong> 
                                            @foreach ($errors->all() as $error)
                                            <p>{{ $error }}</p>
                                            @endforeach
                                        </div>
                                        @endif
@if(计数($errors)>0)
&时代;
错误
@foreach($errors->all()作为$error)
{{$error}}

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

    @error('email')
        <strong>{{ $message }}</strong>
    @enderror
</div>
                                      @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>
                                            </button>
                                            <strong>Error!</strong> 
                                            @foreach ($errors->all() as $error)
                                            <p>{{ $error }}</p>
                                            @endforeach
                                        </div>
                                        @endif