1
I am creating a system and I want to make sure that my user can only make five posts in the database, that is, on the site. What logic would I use to make this kind of permission? Grateful.
1
I am creating a system and I want to make sure that my user can only make five posts in the database, that is, on the site. What logic would I use to make this kind of permission? Grateful.
0
Make a select before opening the posting field to check how many posts it has already made.
If you want q be 5 posts per day, make a date field in the database, to count how many posts were made on that same date.
A simple select would already solve.
Something more or less like this:
SELECT count(id_usuario) as contador FROM suatabela WHERE data = datadehoje
then an if with the result
if (contador >= 5) { echo 'ja atingiu o limite'; }
else { include('formdepostagem.php'); }
I believe that is the logic you seek. If not, try to give more details.
This resolves @Fernandovr. Thank you
Magina friend, we’re together ^_^
Browser other questions tagged php mysqli
You are not signed in. Login or sign up in order to post.
Count how many records there are and, if there are 5 yet, allow registration; otherwise, do not allow.
– Woss
Thank you Anderson. But how would I do that? It’s that I’m a layman. I do an if by taking the value that’s in the bank? Is that I don’t know how to do this query
– Francis Vagner da Luz
It depends a lot on your application. How is the table in the database structured? How do you identify which user is accessing the application?
– Woss
I have a table called posts and in it has a field where I send the user id
– Francis Vagner da Luz
Edit the question and add these details. Table structure, including column configuration, and how you are managing the user with PHP, whether you are storing in session, what code, etc.
– Woss
Okay, just a moment
– Francis Vagner da Luz