所以我有一个非常基本的控制器位于:app/Http/Controllers/RentalRequestController
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('/', 'RentalRequestController@store');
然后我在我看来有以下表格:
<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.
谁能告诉我我做错了什么?
答案 0 :(得分:1)
你应该添加:
{{ csrf_field() }}
在<form>
元素内部,例如:
<form id="rentalForm" name="rentalForm" role="form" action="/" method="post">
{{ csrf_field() }}