遵循教程notfoundhttpexception

时间:2014-03-09 18:53:33

标签: exception laravel laravel-4 laravel-routing

我对框架和laravel很新,我很努力学习laravel,我找到了这本书。

https://leanpub.com/learninglaravel

我希望是一个好的开始。 (通常我用php和html编码)

我在基本教程之后遇到了问题(:/不是一个好的开始大声笑)

routes.php文件

Route::post('contact', function()
{

$data = Input::all();
$rules = array(
'subject' => 'required',
'message' => 'required'
);
$validator = Validator::make($data, $rules);


 if($validator->fails()) {
 return Redirect::to('contact')->withErrors($validator)->withInput();
 }
 return 'Your message has been sent';

 });



Route::get('/', function()
{
return View::make('home');
});
Route::get('about', function()
 {
return View::make('about');
});

Contact.blade.php

@extends('layout')
@section('content')
<h1>Contact Us.</h1>
<p>Please contact us by sending a message using the form below:</p>
{{ HTML::ul($errors->all(), array('class'=>'errors'))}}

{{ Form::open(array('url' => 'contact')) }}
{{ Form::label('Subject') }}
{{ Form::text('subject','Enter your subject') }}
<br />
{{ Form::label('Message') }}
{{ Form::textarea('message','Enter your message') }}
<br />
{{ Form::submit() }}
{{ Form::close() }}
 @stop

其他页面效果很好

1 个答案:

答案 0 :(得分:0)

您需要另一条路线来显示联系表格页面

Route::get('contact', function() {

    return View::make('contact');

});