PHP Laravel how to use two forms in one view


I'm building aLaravel-app where I have two forms in oneblade-template, which appears depending on which tab is active.

It looks like this:

<div data-contact-form-id="1" id="contact-company">
  <form method="POST" action="{{ route('') }}">
  // bunch of input fields here
<div data-contact-form-id="2" id="contact-private">
  <form method="POST" action="{{ route('') }}">
  // bunch of input fields here

then myweb.php

Route::post('contact', '[email protected]')->name('');
Route::post('contact/company', '[email protected]')->name('');

but I can't submit the "company-contact" form, and when I try to do remove the slash in the route I get an is not defined:

Route::post('contact', '[email protected]')->name('');
Route::post('contact', '[email protected]')->name('');

Why is this and how can I solve this?




put all input fields in a single form and submit to the store route.

In controller:

Here I used the company model & some fields just for example you can replace with your model & your field name

public function store(Request $request){
  $post = $request->all();

      'company_name' => $post['company_name']
      'company_email' => $post['company_email'],
      'company_phone' => $post['company_phone']

   // another model for contact
     'name' => $post['name'],
     'email' => $post['email'],
     'phone' => $post['phone'],

People are also looking for solutions to the problem: How to parse PHP Doctrine Querybuilder DateTime from a HTTPResponseMessage to C# DateTime?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.