Lets say that you have a form on your page where guests can submit data and you want them to be able to view the data they they've submitted right after. In my case, I'm using a submission form where residents can submit concerns about a community that they live in. When they submit the data, I want the view page to show the data with their "ticket" (record ID) number after submission. What I don't want is them to be able to change the record id number in the address bar to view other submitted data to see phone numbers, emails, addresses, names, etc.
The way I got around this was to make to make the add page go to the view record page after submission, but only allow that view page to be loaded once before making it hidden. So do this, I added a field called 'is_visible' to the table. I set this as a INT field, to flag it as either 0 or 1. On the add page events in Before Record Added, I add the following code:
$values["is_visible"]='0'
On the view page events, Process Record Values, I have the following code:
if ($values["is_visible"] == 1)
{
header("Location: contact_add.php?page=add");
exit();
}
What this piece of code does is look for the value of is_visible to see what the flag is set as. If it's 0, which is what happens when the form is first submitted, they can view the page. If it's set as 1, then they cannot view the page and it will go back to the add page of the form.
On the view page events, Before Display, I have the following code:
DB::Query("update contact set is_visible='1' where id = ".$values["id"]."" );
This will set the flag to 1, making the view page only visible once after submission so they can see the data that was submitted as a confirmation.