henryhenry Posted March 15, 2007 Share Posted March 15, 2007 I have a bit of an issue with refreshing pages...When you hit refresh, the script resends any SQL queries to the DB (the page is handled on the same page). This is particularly annoying on a form with INSERT queries.I have tried the following (which work but aren't great)- look up data and compare before the insert/update- make columns unique in database- redirect using headers() but can be a pain if 'headers already sent'I would love just to use a simple variable to tell me if the page was refreshed and if so not to run queries! Does anyone know a trick that can make this work?Thanks!Henry Link to comment Share on other sites More sharing options...
justsomeguy Posted March 15, 2007 Share Posted March 15, 2007 You can set a cookie when you do the insert, include the info that you just inserted in the cookie, and if you get a request for an insert and there is a cookie that contains the same info, then ignore the insert.Actually, the session would be better for that then cookies. Link to comment Share on other sites More sharing options...
Nakor Posted March 15, 2007 Share Posted March 15, 2007 Or you could add code to your SQL commands to not execute the commands if a table, column, cell, or anything already exists. I think that would be easier. Link to comment Share on other sites More sharing options...
justsomeguy Posted March 15, 2007 Share Posted March 15, 2007 I think the statements are probably insert statements, not dealing with table creation or altering a table, so the presence of a field in the table wouldn't tell you if an insert occured 5 seconds ago. Link to comment Share on other sites More sharing options...
Nakor Posted March 15, 2007 Share Posted March 15, 2007 Good point. It all just depends on what it is that they are doing. I suppose that I missed that part that said that he was going to be using the same form that submits the data to insert it. In that case you are definitely right. Link to comment Share on other sites More sharing options...
henryhenry Posted March 16, 2007 Author Share Posted March 16, 2007 HelloYes it was primarily insert/update/delete - I am using software to make tables/columns...The cookie method sounds perfect! I will definitely be giving that a try! Thanks once again! This forum is sooo helpful!Henry Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now