|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-11-15 08:10 UTC] renjuchacko at sify dot com
[2004-11-15 08:18 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 22 12:00:01 2025 UTC |
Description: ------------ I have coded a page in php to add/edit/delete some values. The three actions are checked with the help of get variables. The problem is when i submit the page once, the values are getting entered to the database twice. That is, two records are created with the same values. I am using a header("location: ...") function to the same page with change in the query string. I have watched that the same location (as when adding) is retained and getting submitted even if i had coded for a change in location using header function. The interesting thing is that this not happening always. Sometimes it works correctly. Many of my friends had the same issues and i was totally stuck with the problem. Please help me out on this issue. Reproduce code: --------------- Create a page which have the codes of insert, update, delete with actions distinguished by the querystring values like add=yes, update=yes, delete=yes These values are checked like if (isset($HTTP_GET_VARS["add"]) && $HTTP_GET_VARS["add"]=="yes") When i click on the add button, i have written a javascript to submit the page, which will be like pagename.php?add=yes after the insert query is executed, the next statement is to call the same page with different querystring values. This will be like header("location: pagename.php?id=newidcreated"); exit(); Expected result: ---------------- Only a single entry is to be made to the table. Actual result: -------------- Sometimes the data is submitted twice and two entries with the same details are getting posted to the table, which leads to duplicate values.