Say you have 2 scripts: index.php which displays a list of items and delete.php which deletes the items (it processes the request only).
I send the IDs of the items to be deleted from Index.php to delete.php through a form but I want to send those IDs back to index.php so that I can prompt the user that he just deleted those items and present him with an undo possibility.
How do I get the IDs to index.php back from delete.php?
The only way I know how to send variables form script to script is through $_post, $_get, which require form submission and $_Session, which I don’t think suits the purpose because I’m looking for something more temporary…
Easiest way is a $_GET request. Since you don’t actually do any processing after this point and just want to display a message, it doesn’t really matter if a user changes things in the $_GET request
How do you pass things to $_SESSION without submission?
No matter what you do, you’re going to have to submit something. PHP does not work in real time. (AJAX submits, just the same as any form)
You can destroy session variables as easily as you can create them, but you’re still going to have to submit them via GET or POST in order to get them into the array, unless you somehow already know what the user wants to do before you present the webpage.
I thought about a DB approach but wouldn’t that be resource intensive? I already have a flag saying an entry is in the “recycle bin”. Once it’s deleted, it’s out and I don’t want to keep a reference to it.
It’s there a simple way to make a variable from script to script that’s destroyed as soon as it’s used?