rur2641 rur2641 - 1 year ago 92
PHP Question

How to post to a database from a form

How to post the contents of a form to db? I know the database works.

<form method="post" action="{{ action('UserController@registration') }}">
<h1>Please Name</h1>
<textarea name="name"></textarea>
<button type="submit">Access</button>

Route::post('/registration', 'UserController@registration');

public function registration(Request $request)
DB::table(‘user2s’)->insert([‘name’=> $request->name]);
return 'success';

Answer Source

Add this token in your form

{!! Form::token() !!}

or this

<input type="hidden" name="_token" id="csrf-token" value="{{ Session::token() }}" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download