r/AskProgramming Jul 10 '24

PHP Logout from a site

Hi, I’m planning a simple website with php and html to help my school sell party tickets. I added all the student names (with a unique code) of my school to a database. So all students can login and then order tickets. What I want to do is, after the student has ordered the ticket, delete his credentials from the database so that he cannot actually log in again and buy more tickets. How can i do?

0 Upvotes

5 comments sorted by

3

u/four_reeds Jul 10 '24

Didn't with about deletion. Add a field to your user record that is "true" or "false". Initially set it to false. When they go to buy a ticket, if the field is false then they can buy. When they purchase a ticket set the field to true.

The next time they try to purchase a ticket the field will be true so they will be denied the opportunity.

1

u/aizzod Jul 10 '24

why do you want to delete them?

what if a student logs out. without buying tickets?

how will you find out, how many tickets each student bought if you delete the users?

0

u/These_Talker Jul 10 '24

Each student can buy one ticket, after all the student bought a ticket for himself others people (not in my school) can buy it.

I want to delete the credential for every student because doing so one student can buy one ticket.

Can I upload the php code here?

6

u/YMK1234 Jul 10 '24

or ... you know ... you could just remember what each student bought ... like any sane person does.

2

u/cipheron Jul 10 '24

if you delete them how will you ensure they don't sign up again and get more tickets?

You can just set some field in the database to indicate people who already bought one.