Pass variable between foreach loop and popup, no redirect
Hello,
I have an array of card data that I'm fetching from an external source on pageload, and then echoing in a foreach loop into a formatted table.
On each row, I have a button to allow the user to delete the row, with a popup to confirm their decision. Each card has a unique ID so I know which set of data to apply actions to, however it isn't stored locally as it's payment information.
To delete a card, I need the card ID, in the foreach loop the card ID is stored in $card, however when a user clicks on the button to delete the card, I do not redirect the page - instead I show a popup to clarify their decision.
The issue is when I use the $card variable to perform an action. Either it applies to every card, or it only applies to the first card in the table. I don't want to store the $card id in a hidden variable, or echo it onpage as it is sensitive information.
I would store the card in an array, however there is no limit to the amount of stored cards one user can have, therefore I might run into issues if a user has more than I have allocated.
What is the best way of associating a button with a PHP variable without the posibility of the user finding this information out?
The payment processor I'm using is Stripe.
Thanks for your time
Posted Apr 15, 2016, 2:15 AM UTC