Now i send my form data to email account, [email protected], using function:
public function ContactExemple()
{
$email = Input::get('email');
$subiect = Input::get('phone');
Mail::send('email', [
'name'=>Input::get('name'),
'email'=>$email,
'phone'=>$phone,
'msg'=>Input::get('msg')
], function($m) use($email, $subiect) {
$m->from($email);
$m->to(' [email protected]')->subject($subiect);
});
return Redirect::to(URL::previous() . "#contact_form")->with('message', 'THANKS FOR YOUR MSG!');
}
And my VIEW:
< ----form action="{{url('/'.$lang)}}" method="POST" >
{!! csrf_field() !!}
<---input type="text" name="name">
<----input type="email" name="email">
<---input type="text" name="phone" >
<---textarea name="msg"><------/textarea>
<----input type="submit" value="submit" name="submit">
@if(Session::has('message')) {{Session::get('message')}}
@endif
<----/form>
Routes:
Route::get('/', 'HomeController@index');
Route::post('/', 'HomeController@ContactExemple');
I need to do this using AJAX, but can't find anything that can help me to do this, there is a lot of examples with simple ajax post request, but i need to integrate it with sending to my email account this form data.
Or in this way but WITHOUT REFRESHING PAGE, and place a success message..
Thanks !