title: How to redirect to a route from a controller method
body: <p>I have defined a method in my controller, where inputs are first retrieved, and if the email field is present in my database, I would like to return a view. However, if the email field isn't present, I would like to redirect to another route. I would also like to pass in the inputs to that route as well. </p>
  
  <p>To better understand what I mean, my code is as follows for my controller:</p>
  
  <pre><code>    public function index(Request $request) {
  
      $credentials = $request-&gt;all();
  
      if (\App\User::where('email','=',$credentials['email'])-&gt;exists()){
  
          //if they are registered, return VIEW called welcome, with inputs
  
          return view('welcome', $credentials);
  
      }
      else{//If the user is not in the database, redirect to '/profile' route,
           //but also send their data
  
          return redirect('profile', $credentials);
  
      }
  </code></pre>
  
  <p>And my web.php is as follows:</p>
  
  <pre><code>Route::post('/profile', function() {
       $m = Request::only('email'); //I only need the email
       return view('profile', $m);
  });
  </code></pre>
  
  <p>However, this logic fails with errors: 'HTTP status code '1' is not defined'. 
  Is there anyway to do this properly? (i.e. go from my controller method to another route?)</p>