removing url get data or performing action only once?

greg's picture

He has: 1,581 posts

Joined: Nov 2005

I have Page 1 and Page 2

On page 1 I have a bunch of checkboxes, and a submit button that actives the form upon click
This form goes to page 2 and does whatever with the form results (not important)

Now, on page 2 I have a clause where if the user never ticked/selected a box, it sends them back to the previous page and displays "nothing selected" message and all the checkboxes again

the redirect on page 2 if no checkboxes ticked is


if(!$_GET['check']) {
header('Location: page1.php?checkbox=none']
}
'

the message on page 1 is then displayed IF URL data is present, sent by HEADER LOCATION in page 2

if ($_GET['checkbox'] == "none") {
echo 'You did not select any files to delete';
}
'

BUT
When I press refresh page (browser refresh) I want that message to be gone
I wouldn't mind as much if this was only for the refresh, but say a user ignores that and chooses another page, page 3, 4, 5 or whatever
then uses the browser back button and gets to this same page
they still have the message "you did not select a checkbox" but of course thats old news, and in my opinion ugly for the user to see.

variables are of course reset on page refresh, so I couldnt simply use
IF $var==1 "display message" $var =2
Superglobal might work, but seems 'overkill' as there must be a simpler way?
And most of the 'usual' methods of course generally require user input

cheers!