PHP Tutorials: Register & Login (Part 8): Disable/Ban User Accounts

preview_player
Показать описание

Official site

Twitter
Рекомендации по теме
Комментарии
Автор

Who needs paid services when we have Alex as our PHP friend. Sure hope people donate so we keep getting more PHP goodness. Thanks for everything Alex.

ultrageekChris
Автор

For sure I will donate my first project 10% to Alex..

ABMehrabi
Автор

@George Alexander, you're quite right, there's no connection between 'activated' account and 'banned' account. I went ahead and added another column 'banned' with default set to 0 and also added a function named 'user_banned()' very similiar to 'user_active()'.

NeverInterpreter
Автор

So, basically for a secure system where users can actually be banned you either need to make the activation link/token 1 time use, or expire after a period of time. Either that or change the ban/disable altogether or adding fields in the database specifically for this like a "user_banned" and using it with the same code except replacing "active" with "user_banned" in some parts of the code and adding it on other parts ...Unfortunately, I'm still learning PHP, so idk how to do this yet.

anduoo
Автор

very informative and functional! I am a newbie and this tutorial is a great help!

evemaria
Автор

I have learnt so much from you Alex . Thank you very much

nishantve
Автор

Why is it exit() method used? If later there aren't any commands (except $errors) ?

KrzysztofChrzan
Автор

I can do this but make new functions like a 2 and a 3 in 'active' table for "Temporarily Banned" and "Permanently Banned" with basically the same code I've already learnt from Alex, right?

YouLiamTube
Автор

Can we get another method for: "Disable/Ban User Accounts"? I've already tried this and if the user keeps their activation email they can basically re-activate their account with the link in their mail each time you try to disable/ban them...so this method doesn't really work that well

anduoo
Автор

i added redirect to deactivated.php in wich it says: "your account has ben deactivated. you will be redirected to homepage in 10 seconds" (countdown timer).. so the user knows his account has been deactivated and not scratch his head wondering why is getting the homepage everytime and start bugging the pc thinking it's smth wrong with it.

mugenlords
Автор

when i use index.php the page is not redirected but when i use logout.php it works and redirect to the logout page

vaibhavtyagi
Автор

As soon i have got my first salary, i will donate to Alex ! hahah

TheRoxasth
Автор

First of all I wanna thank you, your Tutorials are very helpful.
But my question is:
Why don't you just save the "active" field in $user_data?
like this:
$user_data = user_data($session_user_id, 'lastname', 'firstname', 'active');
and then check if user is "banned"
if($user_data['active'] == 0)
session_destroy();

I mean you could save 1 sql query, (faster?)
or is there any, IDK security reason, for "splitting this up" ?

GunjahPrime
Автор

when i put this code ....--if (user_active($username) === FALSE) { session_destroy(); header('Location: index.php'); exit(); }--*... i cannot loggin
help please

tonyxhepa
Автор

Is there anything this guy can't do?

MrVideoAndroid