I have two contact forms on same page (bootstrap modal window). The problem is that one of them doesn't work correctly and return 404 Not Found
error.
I have this in web.php
Route::post('/b2b_contact','HomeController@b2b_contact')->name('b2b_contact');
Route::post('/','HomeController@contact')->name('contact');
HomeController.php
functions
public function contact(Request $request)
{
$data = array(
'first_name' => $request->first_name,
'company_name' => $request->company_name,
'country' => $request->country,
'email' => $request->email,
);
DB::table('contact')->insert($data);
return Redirect::to('/')->with('message', 'Thank you!');
}
public function b2b_contact(Request $request)
{
$data = array(
'first_name' => $request->first_name,
'company_name' => $request->company_name,
'country' => $request->country,
'email' => $request->email,
);
DB::table('b2b_contact')->insert($data);
return Redirect::to('/')->with('message', 'Thank you!');
}
And what I have in the blade template are the forms
{{Form::open(array('route'=>'b2b_contact','files' => true,'method'=>'post', ))}}
// input fields here
{{Form::close()}}
{{Form::open(array('route'=>'contact','files' => true,'method'=>'post', ))}}
// input fields here
{{Form::close()}}
The second form contact
works perfectly but the b2b_contact
return Error 404.
I've also tried to make both routes in web.php like Route::post('/',....
but then the page return error that b2b_contact
route isn't find.
So, can anyone help me here how to have 2 contact forms on same page and when they are submitted to reload the page and show the success message?
UPDATE: this is what I see when I submit the page and yes, debug is set to true
Not Found
The requested URL /applyNow was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
UPDATE 2: .htaccess
file in public directory
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>