working with laravel 8 project. in my localhost it is working properly. but when I host my project to live server (hostgrator) my controller not working here. I have following web.php route file
use Illuminate\Support\Facades\Route;
Route::get('/', function () {
return view('welcome');
});
Route::post('form','App\Http\Controllers\UserController@store');
Route::get('/user/verify/{token}', 'App\Http\Controllers\UserController@verifyUser');
even localhost and live server welcome
route working properly. but it seems to be my Route::post('form','App\Http\Controllers\UserController@store');
route not working properly on the live server for my contact form in the following
<section class="contact" id="contact">
<div class="content">
@include('partials.alerts')
<h1 class="heading">Contact Us</h1>
<form method="post" action="{{url('form')}}#contact">
{{csrf_field()}}
<div class="form">
<div class="input-flex">
<input type="text" name="name" placeholder="Name*" /><br><br>
<span style="color:red">@error('name'){{$message}}@enderror</span>
<input type="email" name="email" placeholder="E-mail*" /><br><br>
<span style="color:red">@error('email'){{$message}}@enderror</span>
<input type="tel" class="full-width" name="telephone" placeholder="Phone number*" /><br><br>
<span style="color:red">@error('telephone'){{$message}}@enderror</span>
<textarea cols="2" rows="2" class="full-width" name="message" placeholder="Message"></textarea>
</div>
<button class="conbtn" type="submit">Submit</button>
</form>
</div>
</section>
when I click submit button my live sever encounted following error message
Sorry, this page doesn't exist. Please check the URL or go back a page. 404 Error. Page Not Found.
and my url displaylike this
https://tourman.com/form#contact
but it should be like this if it is work properly like localhost
http://localhost/#contact
my controller file is
protected function store(Request $request)
{
//validate request
$this->validate($request,[
'name' => 'required|max:100',
'email' => 'required|email',
'telephone' => 'required',
]);
$user = new User;
$user->name = $request->input('name');
$user->email = $request->input('email');
$user->telephone = $request->input('telephone');
$user->message = $request->input('message');
$user->save();
$verifyUser = VerifyUser::create([
'user_id' => $user->id,
'token' => Str::random(40)
]);
Mail::to($user->email)->send(new VerifyMail($user));
return redirect('/#contact')->with('info', 'We sent you an activation code. Check your email and click on the link to verify');
}
what can do for fix my problem here