0

I am trying to Pass some values from two text boxes in login.blade.php to the testController and echo the values.Iam getting "Method Not Allowed Exception error" I can't understand why , Please tell me what wrong have i done.. the Flow is Login.blade.php -> testController@getIndex

web.php

Route::get('welcome','testController@getIndex');
Route::get('login','testController@getLogin');
Route::get('/','testController@getData');

testController.php


class testController extends Controller
{
   public function getIndex(Request $request)
   {
    $email = $request->get('email');
    $password = $request->get('password');
    echo $email;
   }
   public function getData(){
    $datas = Test::all();
    return view('welcome',compact('datas'));
     }
   public function getLogin()
   {
    return view('login');
   }

}

login.blade.php

{!! Form::open(['Url' => 'welcome']) !!}
    {!! Form::label('email','Email') !!}
    {!! Form::text('email',null,array('class' => 'form-control',   'placeholder' => 'Email' ) ) !!}

    {!! Form::label('password','Pasword')!!}
    {!! Form::text('password',null, array('class' => 'form-control', 'placeholder' => 'Password')) !!}
    {!! Form::submit('Login',array('class' => 'btn btn-success btn-block','style'=>'margin-top: 20px;'))!!}
{!! Form::close() !!}

1 Answers1

0

When using Form::open() - if you don't specify a method (GET or POST), it will default to submitting the form as a POST request. You have your welcome route set up to handle a GET request.

For a login form, I'd recommend you stick with a POST request, which will require you to update your route definition to;

Route::post('welcome','testController@getIndex');

For future reference, you can specify a method when opening your form as follows:

{!! Form::open(['url' => 'welcome', 'method' => 'GET']) !!}

Darren Taylor
  • 1,975
  • 14
  • 18