dongyang2229 2017-02-28 13:18
浏览 12
已采纳

auth ::尝试不能正常工作

My login in laravel isnt working properly. I've been stuck here for a long time now. This is my login controller code

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;


class UsersController extends Controller
{
protected function dashboard(Request $request)
{

    if (Auth::attempt(array('account_number'=>$request['accountnumber-login'], 'password'=> $request['txt-password']))) {
        return redirect()->intended('viewdashboard');
    }

} 

protected function viewdashboard()
{
    return view('dashboard');
}
}

..in this controller the 'account-number' is the account number column in the database and the 'password' is the password column in the database. I've done everything correctly yet it does not redirect me to the dashboard view. Please help

and this is my html form

<html>
<form action="dashboard" method="GET">
<input type="number" name="accountnumber">
<input type="password" name="password">
</form

</html>

this is my web route folder

Route::get('dashboard', function(){
return view('dashboard_view');
}

pls help, please.

  • 写回答

2条回答 默认 最新

  • dongmou5628 2017-02-28 13:29
    关注

    You're not using the UsersController in the route.

    Route::get('dashboard', 'App\Http\Controllers\UsersController@dashboard');
    

    Also you are accessing request data the wrong way.

    Use

    $request->input('accountnumber');
    

    EDIT:

    And thirdly the dashboard method must be public

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

报告相同问题?

悬赏问题

  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应