What I am trying to achieve is :
Check if a user (identified with staff_id) has previously attended an event that contains CTF in its name and prevent the user from registering for another CTF event. i.e each user can only register for one CTF event in a lifetime.
I have db Table named event_register which contains all the registration data and has following columns below.
staff_id, event_name, email, name etc.
Below is screenshot of my Server Action which is supposed to
- Collect
staff_id
andevent_name
from the form. - Check if
event_name
contains “CTF” (case-insensitive). - If it doesn’t, I let the registration proceed.
- If it does, I run a query below to check if that staff_id has previously registered for a CTF event and deny registration :
SELECT COUNT(*) AS count FROM event_register
WHERE staff_id =:staff_id AND :event_name LIKE '%CTF%'
Problem is, even with a CTF event selected for staff_id that has CTF record, the registration still goes through.
Grateful for any help to guide me in the right direction