rur2641
rur2641

Reputation: 699

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>
    </form>

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

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

Upvotes: 0

Views: 62

Answers (1)

Imran Hossain
Imran Hossain

Reputation: 606

Add this token in your form

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

or this

<input type="hidden" name="_token" id="csrf-token" value="{{ Session::token() }}" />

Upvotes: 2

Related Questions