Set a variable on a submit

I have a fillin form , which has a submit button. In order to get to the fillin form, the user has already been authenticated and a session has been created, and variables have been added to the session.

In order to process the information, I have another 'insUpSel.php' file which does two things:

  1. populates a MSSQL database via a stored procedure with the contents of the session
  2. retrieves the results from the MS SQL table and populates an HTML table with multiuple result rows.

I want to prevent users from running the 'insUpSel.php' form manually and if they do force users back to the login page.

Is there a way, where I can update a variable before the processing the fillin form data?

ie. $submitted = true   (on fillin form)
then on the insupsel.php 
i check if $submitted = true
- IF TRUE, I set it back to false and continue processing the data
- IF FALSE, i force the user back to the login page

Many thanks