Hi, how can i stop a mysql update query re-running every time i refresh a page? I want it to run once and that’s it. I tried using a variable and if statement to only run once but this didn’t work. Is there a way to redirect page and not update when the refresh button is pressed?
@NogDogMar 12.2006 — #If you're using session control, then you could set a $_SESSION value upon completion of the query, and add an if clause that only does the query if that session value is not set or is not set to that value.
first page creates session variable called sqlupdated - its a boolean and set to false. A link to a new page sends a url variable, testvar ( tested against to ensure someone going direct to update page does not trigger update ). this page has following php:
By my logic, when you initally go to the new page, sqlupdated will be false, as set in previous page, and testvar will exist cos it sent from previous page so the if statement is run, and this is exactly what happens. However, when i refresh the page, the if statement still runs, whereas i thought it would be the else because i have set sqlupdated to true. What am i doing wrong here?
@mcpalmerauthorMar 13.2006 — #Fixed, i wasn't renewing the session when i went to the new page. Anyway, I found a non-sessions approach to use in the end and decided to go with that, cheers