我正在尝试做这个联系表格,但我是:(
{{ Form::open(array('url' => 'PagesController@contact', 'method' => 'POST', 'role' =>'form', 'class' =>'form-horizontal' )) }}
<div class="form-group">
{{ Form::label('name', 'Nombre:', ['class' => '']) }}
{{ Form::text('name', '', ['class' => 'form-control', 'maxlength' => 20]) }}
</div>
<div class="form-group">
{{ Form::label('email', 'Email:', ['class' => '']) }}
{{ Form::email('email', '', ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('subject', 'Asunto:', ['class' => '']) }}
{{ Form::text('subject', '', ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('country', 'Pais:', ['class' => '']) }}
{{ Form::text('country', '', ['class' => 'form-control']) }}
</div>
<div class="form-group">
{{ Form::label('textarea', 'Message:', ['class' => '']) }}
{{ Form::textarea('msg', '', ['class' => 'form-control', 'placeholder' =>'Your Message', 'required'=>'true']) }}
</div>
<div class="form-group">
{{ Form::submit('Send', array('class' => 'btn btn-primary btn-md')) }}
</div>
{{ Form::close() }}
Name: {{ $name }}
Email: {{ $email }}
Country: {{ $country }}
Subject: {{ $subject }}
Message: {{ $msg }
return array(
'driver' = 'smtp',
'host' = 'smtp.gmail.com',
'port' = 587, <br/>
'from' = array('address' = 'africamia@gmail.com', 'name' = 'Admin'),
'encryption' = 'tls',
'username' = 'africamia@gmail.com',
'password' = '123456',
'sendmail' = '/usr/sbin/sendmail -bs',
'pretend' = false,
);
public function contact()
{
$validation = New ?? I don't know what I do here :(;
if($validation->passes()) {
$fromEmail = Input::get('email');
$fromName = Input::get('name');
$subject = "Email from someone at website.com";
$data = [ 'msg' => Input::get('message') ];
$toEmail = 'africamia83@gmail.com';
$toName = 'Admin';
Mail::send('emails.contact', $data, function($message) use ($toEmail, $toName, $fromEmail, $fromName, $subject){
$message->to($toEmail, $toName);
$message->from($fromEmail, $fromName);
$message->subject($subject);
});
return Redirect::to('/gracias')
->with('message', 'Your message was successfully sent!');
}
return Redirect::back()
->withInput()
->withErrors($validation->errors);
}
Route::get('contact', array('as' =>'contact', 'uses'=> 'PagesController@contact'));
Route::get('contact', function() {
return View::make('contact');
});
当我点击n提交按钮时,在浏览器中显示:../ public / PagesController @ contact
异常处理程序出错:未为PagesController @ contact
定义Route [/]答案 0 :(得分:0)
当您提交for时,它是POST
请求,而不是GET
。您将其定义为GET
请求。请更改路径文件,如下所示:
Route::post('contact', 'PagesController@contact');