your localhost say that you are not an authorized person to log in, you must have credentials :)
meanwhile, you have signup or register option as well on the screen
fille the form and register again
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I can login to my project with via: http://localhost/ecom/public/en/admin/login but when i ran php artisan serve it refused to login , any help would be much appreciated !
your localhost say that you are not an authorized person to log in, you must have credentials :)
meanwhile, you have signup or register option as well on the screen
fille the form and register again
Hey @a4ashraf , thanks for your support !
Normally with the same credentials i logged in via http://localhost/ecom/public/en/admin/login but with php artisan serve it refused ,
"fille the form and register again" YES i filled the login form with the right credentials but still the same
"you have signup or register option as well on the screen" if you are talking about the default login form of laravel, yes but i have a custome login form
Share your migration, model, and controller files
Great ! Here my login method
public function processLogin(AdminLoginRequest $request){
try {
$remember_me = $request->has('remember_me') ? true : false;
if(Auth::guard('admin')->attempt(['email'=>$request->email, 'password'=>$request->password], $remember_me)){
return redirect()->route('admin.dashboard');
//return 'hy admin';
}else{
return redirect()->back()->with('error','Email and Password are not correct !');
}
}catch (\Exception $ex){
return $ex;
}
}
=login from in view
<form class="form-horizontal form-simple" action="{{route('process.login')}}" method="post">
@csrf
<fieldset class="form-group position-relative has-icon-left mb-0">
<input type="text" name="email" class="form-control form-control-lg input-lg"
value=" " id="email" placeholder="Email ">
<div class="form-control-position">
<i class="ft-user"></i>
</div>
@error('email')
<span class="text-danger">{{$message}} </span>
@enderror
</fieldset>
<fieldset class="form-group position-relative has-icon-left">
<input type="password" name="password" class="form-control form-control-lg input-lg"
id="user-password"
placeholder="Password">
<div class="form-control-position">
<i class="la la-key"></i>
</div>
@error('password')
<span class="text-danger">{{$message}} </span>
@enderror
</fieldset>
<div class="form-group row">
<div class="col-md-6 col-12 text-center text-md-left">
<fieldset>
<input type="checkbox" name="remember_me" id="remember-me"
class="chk-remember">
<label for="remember-me"> remember me</label>
</fieldset>
</div>
</div>
<button type="submit" class="btn btn-info btn-lg btn-block"><i class="ft-unlock"></i>
login
</button>
</form>
=Admin Model
class Admin extends Authenticatable
{
protected $table = 'admins';
public $timestamps = true;
protected $guarded = [];
}
where you create this admin guard in your config file and what is this AdminLoginRequest plz share these files
or try this one
public function processLogin(Request $request){
try {
$remember_me = $request->has('remember_me') ? true : false;
if(Auth::attempt(['email'=>$request->email, 'password'=>$request->password], $remember_me)){
return redirect()->route('admin.dashboard');
//return 'hy admin';
}else{
return redirect()->back()->with('error','Email and Password are not correct !');
}
}catch (\Exception $ex){
return $ex;
}
}
Hey @a4ashraf , thanks for your support !
=I tried your method and gave me the same error
=AdminLoginRequest it's a validator
public function rules()
{
return [
'email'=>'required',
'password'=>'required',
];
}
= in config,in auth.php with guards
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
=
'admins' => [
'driver' => 'eloquent',
'model' => App\Models\Admin::class,
],
what is an error btw, show me the error
had you check your .env file and DB setting
and also have you include this Auth Facades
use Illuminate\Support\Facades\Auth;
The error is : Email and Password are not correct !, The .env file is correctly set, therefore i could logged in without any problem with via a direct link to my project i guess
I did run these commands but did not solved the problem, thanks !
Please or to participate in this conversation.