I am trying to insert data into my database name Client using a bootstrap form. But if I click submit button the page just directed to newClintForm page without inserting any value into the Client database. I am using laravel version 5.0. This is the Form part of newClientFormblade template -
<form role="form" method="post" action="{{url('clients/newClientForm')}}">
<input type="hidden" name="_token" value="{{csrf_token() }}">
<div class="form-group">
<label>Name</label>
<input class="form-control" name="ClientName" placeholder="Erfan">
</div>
<div class="form-group">
<label>Client ID</label>
<input class="form-control" name="ClientID" placeholder="Ect112">
</div>
<div class="form-group">
<label>Phone No.</label>
<input class="form-control" name="Phone" placeholder="01XX-XXXXXXX">
</div>
<button type="submit" class="btn btn-default">Submit Button</button>
</form>
instead of csrf_token() I tried Session::token() but didn't help either.
This is my controller part-
public function newClientFormIndex(){
return view('clients.newClientForm');
}
public function store(Request $request)
{
$client = new Client();
$client->ClientID = $request->ClientID;
$client->ClientName = $request->ClientName;
$client->Phone = $request->Phone;
$client->save();
}
this is the Model part-
class Client extends Model {
protected $table = 'clients';
public $timestamps = false;
protected $primaryKey = 'ClientID';
protected $fillable = ['ClientID', 'ClientName', 'Phone'];
}
I can't find where the error is ! Any kind of help is appreciated.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire