From: renjuchacko at sify dot com Operating system: Windows 2000 Professional PHP version: 4.3.9 PHP Bug Type: Output Control Bug description: Header Problem in PHP when submitting a form
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. -- Edit bug report at http://bugs.php.net/?id=30771&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30771&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30771&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30771&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=30771&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=30771&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=30771&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=30771&r=needscript Try newer version: http://bugs.php.net/fix.php?id=30771&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=30771&r=support Expected behavior: http://bugs.php.net/fix.php?id=30771&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=30771&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=30771&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=30771&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30771&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=30771&r=dst IIS Stability: http://bugs.php.net/fix.php?id=30771&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=30771&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=30771&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=30771&r=mysqlcfg