title: Laravel 5.1 Login Controller Doesnt Work Well
body: <p>I'm new to laravel.  I have a problem with my login control where I can't match the data from my form and the database.</p>
  
  <p>The error message said : </p>
  
  <blockquote>
    <p>DecryptException in BaseEncrypter.php line 45: The payload is invalid.</p>
  </blockquote>
  
  <p>Controller
      
  
  <pre><code>namespace App\Http\Controllers;
  
  use DB;
  use Hash;
  use Crypt;
  use Validator;
  use Illuminate\Http\Request;
  use App\User;
  use App\Http\Requests;
  use App\Http\Controllers\Controller;
  
  
  class LoginControl extends Controller
  {
  
      public function login(Request $request)
      {
          $validator = Validator::make($request-&gt;all(), [
              'email' =&gt; 'required',
              'password' =&gt; 'required',
          ]);
  
          if ($validator-&gt;fails()) {
              return redirect('/login')
                          -&gt;withErrors($validator)
                          -&gt;withInput();
          }
          else{
              $email = $request-&gt;email;
              $password = $request-&gt;password;
              $results = DB::select('select * from users where email = ? and password = ?', [$email,$password]);
              $pass = Crypt::decrypt($request-&gt;password);
              if($results == NULL){
                  return redirect('/login');
              }
              else{
                  return redirect('/');
              }
          }
      }
  }
  </code></pre>
  
  <p>Router</p>
  
  <pre><code>&lt;?php
  
  Route::get('/', function () {
      return view('welcome');
  });
  
  Route::get('/register', function () {
      return View::make('register');
  });
  
  Route::get('/login', function() {
      return View::make('login');
  });
  
  Route::post('actionregis', 'RegisControl@store');
  
  Route::post('actionlogin', 'LoginControl@login');
  </code></pre>
  
  <p>View</p>
  
  <pre><code>&lt;html lang="en"&gt;
      &lt;head&gt;
          &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"&gt;
          &lt;title&gt;Laravel Quickstart - Basic&lt;/title&gt;
  
          &lt;!-- CSS And JavaScript --&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;div class="container"&gt;
              &lt;nav class="navbar navbar-default"&gt;
                  &lt;!-- Navbar Contents --&gt;
              &lt;/nav&gt;
          &lt;/div&gt;
  
          &lt;div class="panel-body"&gt;
          &lt;div class="col-md-8 col-md-offset-2"&gt;
  
          &lt;!-- New Task Form --&gt;
          &lt;form action="/testing/public/actionlogin" method="POST" class="form-horizontal"&gt;
              {{ csrf_field() }}
  
              @if (count($errors) &gt; 0)
                  &lt;!-- Form Error List --&gt;
                  &lt;div class="alert alert-danger"&gt;
                      &lt;strong&gt;Whoops! Something went wrong!&lt;/strong&gt;
  
                      &lt;br&gt;&lt;br&gt;
  
                      &lt;ul&gt;
                          @foreach ($errors-&gt;all() as $error)
                              &lt;li&gt;{{ $error }}&lt;/li&gt;
                          @endforeach
                      &lt;/ul&gt;
                  &lt;/div&gt;
              @endif  
              &lt;!-- Task Name --&gt;
                  {!! csrf_field() !!}
  
                  &lt;div class="form-group"&gt;
                      &lt;label for="user"&gt;Email&lt;/label&gt;
                      &lt;input type="text" name="email" id="task-email" class="form-control"&gt;
                  &lt;/div&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label for="user"&gt;Password&lt;/label&gt;
                      &lt;input type="password" name="password" id="task-password" class="form-control"&gt;
                  &lt;/div&gt;
  
                  &lt;div class="form-group"&gt;
                      &lt;input type="checkbox" name="remember"&gt; Remember Me
                  &lt;/div&gt;
  
                  &lt;div class="form-group"&gt;
                      &lt;button type="submit" class="btn btn-default"&gt;Login&lt;/button&gt;
                  &lt;/div&gt;
              &lt;/form&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"&gt;&lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>