First my error was Class Input not found so i added
'Input' => Illuminate\Support\Facades\Input::class,
in aliases array
Now when i submit my form it gives this error
ERROR: MethodNotAllowedHttpException in RouteCollection.php line 219:
Routes.php
Route::post('add', function () {
$name = Input::get('name');
if(DB::table('projects')->whereName($name)->first() != NULL) return 'already exist';
DB::table('projects')->insert(array('name'=>'$name'));
return Redirect::to('/add');
});
welcome.blade.php :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Laravel Learning</title>
</head>
<body>
{!! Form::open(array('url' => 'add')) !!}
{!! Form::text('name', 'Your Name...') !!}
{!! Form::submit('Click Me!') !!}
{!! Form::close() !!}
</body>
</html>
return Redirect::to('/add');
, which will be aGET
url. – Francesco de GuytenaereIf you use the Form::open method with POST, PUT or DELETE the CSRF token will be added to your forms as a hidden field automatically.
, so if you inspect your page source (in browser) I suspect that's already there. – Francesco de Guytenaere