0

I am working on a site in laravel. The email sending form is at the footer of the website. When I send an image, for now it just saves the email in the database. After saving the email, I want to redirect to the footer section of the one-page website but it doesn't. Funny thing is, it works right when validation is removed. here is my form:

<form class="form" method="POST" action="{{ action('IndexController@email') }}">
     <input type="hidden" name="_token" value="{{ csrf_token() }}">
     <input type="text" name="name" class="form-control">
     <input type="email" name="email" class="form-control">
     <input type="text" name="subject" class="form-control">
     <textarea class="form-control" name="message" style="height: 100px;"></textarea>
   <button type="submit" class="btn btn-primary btn-block">Send</button>
</form>

Here is the post route:

Route::post('new/sendemail', ['as' => 'sendemail', 'uses' => 'IndexController@email']);

and here is the controller method:

public function email(Request $request){

$this->validate($request, [
    'name' => 'required', 
    'email' => 'required', 
    'subject'=>'required',
    'message' => 'required'
]);

$input = $request->all();

Email::create($input);

return redirect('new/#contact'); //this is where i want to redirect to that section but it doesn't work

}
A. Apola
  • 131
  • 1
  • 4
  • 13

0 Answers0