Jump to content

Stop Page Revisits


CanMan2004

Recommended Posts

Hi

I have a page which does a query to insert data into a table, but I only want to run the page once as I dont want the same information being added into the database more than once. I have found that if they refresh the page or go back to the page in the history list, the query gets performed again and the data is inserted again.

What is the best way to stop people visiting the same page twice, although if another order is placed I want the page to be accessed again as that would be new information being added.

Can anyone help?

Thanks

Dave
Link to comment
https://forums.phpfreaks.com/topic/35995-stop-page-revisits/
Share on other sites

Do you have a unique field in the database that can tell the difference between each visitor? If you don't that is what you need to to first by adding something to the table where you are inserting the data to.

Then just make a query to the database and check if that information is still there, and if it isn't display the page.

[code]
<?php

$query = mysql_query("SELECT unique_field FROM table WHERE condition");

if ( mysql_num_rows($query) <= 0 ){

  //DISPLAY PAGE

} else {

//DONT DISPLAY PAGE

}

?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/35995-stop-page-revisits/#findComment-170745
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.