1

我遇到了我在 laravel 中遇到的错误。当我在本地主机上运行我的代码时,我没有任何问题,但是当我将 laravel 放在作为服务器('https')的演示实时服务器中时,我得到了 MethodNotAllowedHttpException 错误。

这是我的路线代码

Route::post('post_reminder', function(){
    $creds = array(
        'email' => Input::get('email')
    );

    $rules = array(
        'email' => 'required|email'
    );
    $messages = array(
        'email' => 'The :attribute needs to be an real email'
    );

    $validator = Validator::make($creds, $rules,$messages);

    if($validator->fails())
    {
        return Redirect::route('getReminder')->withErrors($validator);
    }
    else
    {
        return Password::remind($creds);
    }
       });

这是表单代码

    <div id="reset_container">
{{ Form::open(array('url' => 'post_reminder')) }}
<h1 id="pass_recovery_text">Password Recovery Form</h1>
    <p>
@if (Session::has('error'))
    <li id="error">{{ trans(Session::get('reason')) }}</li>
@elseif (Session::has('success'))
        <li id="error">An e-mail with the password reset has beensent.</li>
@endif
@foreach($errors->all() as $error)
    <li id="error">{{ $error }}</li>
@endforeach
{{ Form::label('email', 'Please enter you email: ') }}
{{ Form::text('email','',array('id' => 'forgot')) }}
{{ Form::submit('Reset') }}<br /><br /><br />
{{ HTML::link('/', 'Have a account Sign-In', array('id' => 'sign-in')) }}
    </p>
{{ Form::close() }}
    </div>
4

2 回答 2

1
<div id="reset_container">
{{ Form::open(array('url' => 'post_reminder','method' => 'post')) }}
    <h1 id="pass_recovery_text">Password Recovery Form</h1>
    <p> 
    @if (Session::has('error'))
        <li id="error">{{ trans(Session::get('reason')) }}</li>
    @elseif (Session::has('success'))
        <li id="error">An e-mail with the password reset has beensent.</li> 
    @endif 
    @foreach($errors->all() as $error)
    <li id="error">{{ $error }}</li> @endforeach
    {{ Form::label('email', 'Please enter you email: ') }}
    {{ Form::text('email','',array('id' => 'forgot')) }} 
    {{ Form::submit('Reset') }}
    {{ HTML::link('/', 'Have a account Sign-In', array('id' => 'sign-in')) }} </p> 
{{ Form::close() }}

于 2015-03-20T13:54:28.950 回答
0

您是否尝试过强制通过 https 提供路由?

Route::post('post_reminder', array('https', function(){
$creds = array(
    'email' => Input::get('email')
);

$rules = array(
    'email' => 'required|email'
);
$messages = array(
    'email' => 'The :attribute needs to be an real email'
);

$validator = Validator::make($creds, $rules,$messages);

if($validator->fails())
{
    return Redirect::route('getReminder')->withErrors($validator);
}
else
{
    return Password::remind($creds);
}
   }));

在此处参考http://laravel.com/docs/4.2/routing

于 2015-03-05T09:19:28.703 回答