Slexy.org is shutting down and stopped accepting new Pastes on May 4th, 2021.
Existing Pastes will stop being available on or after May 10th, 2021.
Author: Not specified Language: php
Description: Not specified Timestamp: 2017-08-08 08:10:22 +0000
View raw paste Child paste by: Not specified Reply
  1. //Route
  2. Route::get('dangnhap',function(){
  3.    return view('dangnhap');
  4. });
  5.  
  6. Route::post('login','AuthController@login')->name('login');
  7.  
  8. Route::get('insert', function (){
  9.     $user = new App\User();
  10.     $user->name = "admin";
  11.     $user->email = "admin@gmail.com";
  12.     $user->password = encrypt(12345);
  13.     $user->save();
  14.     echo "Da insert";
  15. });
  16.  
  17. //AuthController
  18. <?php
  19.  
  20. namespace App\Http\Controllers;
  21.  
  22. use Illuminate\Http\Request;
  23. use Illuminate\Support\Facades\Auth;
  24.  
  25. class AuthController extends Controller
  26. {
  27.     //login
  28.     public function login(Request $request){
  29.         $username = $request->username;
  30.         $password = $request->password;
  31.         $login = [
  32.             'name'=>$username,
  33.             'password'=>$password
  34.                 ];
  35.         var_dump(Auth::attempt($login));
  36.         if (Auth::attempt($login))
  37.             echo $username."<br>".$password;
  38.         else {
  39.             echo "ko thanh cong<br>";
  40.             echo $username."<br>".$password;
  41.         }
  42.     }
  43. }
  44. //dangnhap.balde.php
  45. <h1>Dang Nhap</h1>
  46.  
  47. <form action="{{route('login')}}" method="post">
  48.     {{ csrf_field() }}
  49.     <input type="text" name="username" placeholder="User name">
  50.     <input type="password" name="password" placeholder="Password">
  51.     <input type="submit" value="Dang Nhap">
  52. </form>
View raw paste Child paste by: Not specified Reply