dongshi6528 2014-12-04 07:26
浏览 36
已采纳

Laravel 4.2中的MethodNotAllowedHttpException

Hi in my login page I have forgot password link. From where I have to send the reset password links to the users. I hope I did everything correctly, but still I am getting the " MethodNotAllowedHttpException " Error.

HTML Code

<form action="/user/sendresetlink" method="post" id="forgot_password_form" name="forgot_password_form">

    <label for="name" class="col-xs-4 control-label">User Name</label>
    <input type="text" id="user_name" name="user_name" class="form-control"  />

    <button type="submit" class="btn bg-olive btn-block">Send</button>

</form>

Router Code

Route::resource('user', 'UserController');

Here I Have mentioned resource for UserController, where laravel takes care of basic CRUD routings.

Route::get('login', 'UserController@create');

Route::post('/user/store','UserController@store');

Route::get('logout', 'UserController@destroy');

Route::get('forgot_password','UserController@forgotPassword');

Route::post('sendresetlink','UserController@sendResetLink');

I have mentioned the sendresetlink as post and calling the controller. It is not even going to controller.

Route::group(array('before' => 'auth'), function()
{
    Route::get('/jobs', 'JobsController@jobs_list');
});

Controller Code

public function sendResetLink()
{
    $form_data = Input::all();
    echo '<PRE>';
    print_r($form_data);
    exit;
}

What am I doing wrong here? Am I missing anything?

Note: I have installed laravel in another machine and copied over the code to current machine. May be because of that, my php artisan is not working. When ever I tries php artisan in command prompt, it is stating that 'php' is not recognized as any internal external command. I tried to install the composer in the php.exe folder. Even then also no use.

  • 写回答

2条回答 默认 最新

  • doujiaozhan2413 2014-12-04 07:49
    关注

    At app/routes.php you have written

    Route::post('sendresetlink','UserController@sendResetLink');
    

    While at the form action you have

    <form action="/user/sendresetlink" method="post" id="forgot_password_form" name="forgot_password_form">
    

    You can fix this by changing app/routes.php to

    Route::post('user/sendresetlink','UserController@sendResetLink');
    

    There is a miss-match between your route and your form action. /user/ sendresetlink and just sendresetlink.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面