tags:

views:

35

answers:

1

I am creating an online enrollment form. When a user advances to page 2, I generate a 'unique' ID for that user with the following PHP command:

$_SESSION['ConfirmationNo'] = rand(100000000, 999999999);

however, later in the process, when a user can actually view their confirm number, they can simply 'refresh' the page once and a new confirmation number will appear.

Any way to do this where that particular ID is locked down from page 1 or 2?

Thanks!

A: 

you could check if the confirmation number exists in session before generating it. Then if the number exists, either just use that to display previously submitted/saved information or display a message saying "please don't refresh this page".

Jonathan Kuhn
@jonathan - it does not exist before it is generated. A message telling somebody 'not' to refresh a page won't work etiher.
JM4
if the page is refreshed, the session variable will already exist as it was created before they refreshed. If it exists then you know the page was refreshed. the "please don't refresh this page" is a message that will display after they have refreshed the page, letting them know not to do it. really the message is not required, its just to let them know you detected a refresh (because the id exists) and that in the future they shouldn't do it.
Jonathan Kuhn