亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

表單頁面未重定向到 Laravel 中所需的頁面

表單頁面未重定向到 Laravel 中所需的頁面

PHP
森林海 2023-07-01 15:14:32
因此,我制作了一個表單頁面,該頁面應將其輸入值從 laravel 定向到注冊頁面,但在填寫并發送表單后,控制器不會重定向到注冊頁面,<?phpnamespace App\Http\Controllers;use App\Providers\RouteServiceProvider;use Illuminate\Foundation\Auth\RegistersUsers;use Illuminate\Http\Request;use Illuminate\Support\Facades\Validator;use App\Http\Controllers\Controller;use App\User;use Illuminate\Support\Facades\Hash;class InviteController extends Controller{    /*    |--------------------------------------------------------------------------    | Register Controller    |--------------------------------------------------------------------------    |    | This controller handles the registration of new users as well as their    | validation and creation. By default this controller uses a trait to    | provide this functionality without requiring any additional code.    |    */    /**     * Show the application dashboard.     *     * @return \Illuminate\Contracts\Support\Renderable     */    public function index()    {        return view('invite');    }  //        /**     * Where to redirect users after registration.     *     * @var string     */    protected $redirectTo =  RouteServiceProvider::REGISTER;    /**     * Create a new controller instance.     *     * @return void     */    public function __construct()    {        $this->middleware('guest');    }    /**     * Get a validator for an incoming registration request.     *     * @param  array  $data     * @return \Illuminate\Contracts\Validation\Validator     */    protected function validator(array $data)    {        return Validator::make($data, [            'username' => ['required', 'string', 'max:255', 'unique:users']        ]);    }}這是invites.blade.php中的表單方法                <div class="card-body">                    <form method="POST" action="{{ route('register') }}">                        @csrf以及 web.php 中的路由Auth::routes();Route::get('/invite', 'InviteController@index')->name('invite');
查看完整描述

1 回答

?
慕桂英546537

TA貢獻1848條經驗 獲得超10個贊

你必須像這樣使用

<form method="POST" action="{{ route('invite') }}">

而你的routes/web.php使用是這樣的

Route::post('/your_url_name', 'InviteController@your_function_name')->name('invite');


查看完整回答
反對 回復 2023-07-01
  • 1 回答
  • 0 關注
  • 113 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號