Laravel提交形式获取页面过期

所以我必须位于一个非常基本的控制器:app/Http/Controllers/RentalRequestControllerLaravel提交形式获取页面过期

namespace App\Http\Controllers; 

use Illuminate\Routing\Controller as BaseController;

class RentalRequestController extends BaseController

{

public function store(Request $request, $obj)

{

$g = 0;

return view("success");

}

}

然后在我的web.php我有以下几点:

Route::Post('/', '[email protected]'); 

然后我有以下形式在我看来:

<form id="rentalForm" name="rentalForm" role="form" action="/" method="post"> 

<!-- Row -->

<div class="f-row">

<div class="form-group one-fourth">

<label for="address">Gade</label>

<input type="text" name="address" id="address"

data-parsley-required-message="Indtast venligst din gade" required

data-parsley-errors-container="#errAddress"/>

<div class="full-width">

<label id="errAddress"></label>

</div>

</div>

<div class="form-group one-fourth">

<label for="number">Husnummer</label>

<input type="number" name="number" id="number"

data-parsley-required-message="Indtast venligst dit husnummer" required=""

data-parsley-errors-container="#errNumber">

<div class="full-width" style="">

<label id="errNumber"></label>

</div>

</div>

<div class="form-group one-fourth">

<label for="zip">Postnr</label>

<input type="text" name="zip" id="zip" required=""

data-parsley-required-message="Indtast venligst dit postnr"

data-parsley-length-message="Indtast et dansk postnr"

data-parsley-length="[4,4]" data-parsley-zip="dk"

data-parsley-errors-container="#errZip">

<div class="full-width" style="">

<label id="errZip"></label>

</div>

</div>

<div class="form-group one-fourth">

<label for="city">By</label>

<input type="text" name="city" id="city" required=""

data-parsley-required-message="Indtast venligst din by"

data-parsley-errors-container="#errCity">

<div class="full-width" style="">

<label id="errCity"></label>

</div>

</div>

</div>

<!-- //Row -->

<!-- Row -->

<div class="f-row">

</div>

<!-- //Row -->

<div class="f-row">

<div class="form-group one-fourth">

<label for="kvm">kvadratmeter</label>

<input type="number" id="kvm" min="1" class="uniform-input number" name="kvm" required=""

data-parsley-required-message="Indtast venligst arealet på din bolig"

data-parsley-errors-container="#errKvm">

<div class="full-width" style="">

<label id="errKvm"></label>

</div>

</div>

<div class="form-group one-fourth">

<label for="price">Nuværende husleje</label>

<input type="number" id="price" name="price" step="0.01" required=""

data-parsley-required-message="Indtast venligst din nuværende husleje"

data-parsley-errors-container="#errPrice">

<div class="full-width" style="">

<label id="errPrice"></label>

</div>

</div>

<div class="form-group select one-fourth">

<label for="concatSelector">Vælg kontakt form</label>

<div class="selector">

<select id="concatSelector" required="" data-parsley-required-message="Indtast venligst din nuværende husleje">

<option selected="">Vælg kontakt form</option>

<option value="cell">Telefon</option>

<option value="mail">E-mail</option>

</select>

</div>

</div>

<div class="form-group one-fourth fadeIn" id="selectEmail">

<label for="email">Kontakt information</label>

<input type="email" id="email" name="email" placeholder="E-mail" required=""

data-parsley-type="email"

data-parsley-type-message="Indtast venligst en gyldig e-mail"

data-parsley-required-message="Indtast venligst en gyldig e-mail"

data-parsley-errors-container="#errEmail"

>

<div class="full-width" style="">

<label id="errEmail"></label>

</div>

</div>

<div class="form-group one-fourth fadeIn" id="selectCell">

<label for="mobile">Kontakt information</label>

<input type="number" id="mobile" name="phone" placeholder="Telefon" required=""

data-parsley-required-message="Indtast venligst et gyldig telefon nr."

data-parsley-errors-container="#errCell"

>

<div class="full-width" style="">

<label id="errCell"></label>

</div>

</div>

</div>

<div class="f-row">

<div class="form-group right one-fourth" style="margin-top: 35px">

<button type="button" onclick="sendInformation()" class="btn large black">Kan jeg spare penge?

</button>

</div>

</div>

现在,当我提交表单重定向我到一个页面,指出:

The page has expired due to inactivity. 

Please refresh and try again.

谁能告诉我是什么香港专业教育学院做错了?

回答:

您应该添加:

{{ csrf_field() }} 

<form>元素,例如像这样:

<form id="rentalForm" name="rentalForm" role="form" action="/" method="post"> 

{{ csrf_field() }}

这就是所谓的CSRF protection

以上是 Laravel提交形式获取页面过期 的全部内容, 来源链接: utcz.com/qa/264764.html

回到顶部