Jump to content

php sql issue


bluetoother

Recommended Posts

i have a web page to receive users posts in my web site ,,it contain an editor , when user submit he submit to the same page,when the page check if there is a submitted data it insert the data in mysql database.sometimes when the page get submitted data it insert the data in the database 2 or 3 times , i mean same 3 identical records but with different record id which is the primary key and it is different because it is auto increment attribute .i tried to solve this by writing a cookie that remain for 2 minutes on the client's side when the insert sql command get executed , so if the user tried to insert records in shorter time , (IF) statement will prevent this and tell the user that he can insert after 3 mins ,but this didnt work.i cannot find an explanation to what is happening in that page when data is submitted to it.and why sql insert command got repeated more than one time .maybe it is SQL issue and this thread should be posted there .iam on php4 hosting server

Link to comment
Share on other sites

If the code is correct and it is only inserting one row then they are probably refreshing the page which will submit the same data and insert another row. You can get around that by saving the data that was last inserted into the session. When you do the insert check to see if the data to be inserted is the same as the data in the session and if so skip the insert.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...