Msoft

419 Sorry, your session has expired. Please refresh and try again.

Posted 1 month ago by Msoft

I am going to submit contact form data via the email as the following Controller,

public function contactUs()
   {
       return view('contactUs');
   }

   /**
    * Show the application dashboard.
    *
    * @return \Illuminate\Http\Response
    */
   public function contactUsPost(Request $request)
   {
       $this->validate($request, [
        'name' => 'required',
        'email' => 'required|email',
        'message' => 'required'
        ]);

       ContactUs::create($request->all());
        Mail::send('email',
        array(
           'name' => $request->get('name'),
           'email' => $request->get('email'),
           'user_message' => $request->get('message')
        ), function($message)
       {
       $message->from('[email protected]');
       $message->to('[email protected]', 'Admin')
       ->subject('Contact Form Query');
      });
   return back()->with('success', 'Thanks for contacting us!');
   }

and route is,

Route::get('contact-us', '[email protected]');
Route::post('contact-us',[
'as'=>'contactus.store',
'uses'=>'[email protected]'
]);

and contact form

<form action="{{route('contactus.store')}}" method="post">
<div class="form-group row">
    <label for="inputEmail3" class="col-sm-2 col-form-label">Name</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="inputEmail3" name="name" placeholder="Name">
    </div>
  </div>
  
  <div class="form-group row">
    <label for="inputEmail3" class="col-sm-2 col-form-label">Email</label>
    <div class="col-sm-10">
      <input type="email" class="form-control" id="inputEmail3" name="email" placeholder="Email">
    </div>
  </div>
  
   <div class="form-group">
  <label for="comment">Comment:</label>
  <textarea class="form-control" rows="5" name="message" id="comment"></textarea>
</div> 
  
  <div class="form-group row">
    <div class="col-sm-10">
      <button type="submit" class="btn btn-primary">Sign in</button>
    </div>
</form>
 

but when I click submit buttons I got following error massage ` 404

Sorry, the page you are looking for could not be found. ` how can fix this problem?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.