#30771 [Csd->Bgs]: Header Problem in PHP when submitting a form

From: Date: Mon, 15 Nov 2004 07:18:43 +0000
Subject: #30771 [Csd->Bgs]: Header Problem in PHP when submitting a form
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-69069@lists.php.net to get a copy of this message
 ID:               30771
 Updated by:       tony2001@php.net
 Reported By:      renjuchacko at sify dot com
-Status:           Closed
+Status:           Bogus
 Bug Type:         Output Control
 Operating System: Windows 2000 Professional
 PHP Version:      4.3.9
 New Comment:

No bug here -> bogus.


Previous Comments:
------------------------------------------------------------------------

[2004-11-15 08:10:52] renjuchacko at sify dot com

I got this problem solved.

I was using javascript function for submitting the form. That is, i was
calling the javascript function on button click. This was causing the
problem. Now i have changed, and set the action attribute of the form
tag. Now this works fine.

Thank You.

------------------------------------------------------------------------

[2004-11-13 08:53:59] renjuchacko at sify dot com

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 this bug report at http://bugs.php.net/?id=30771&edit=1


Thread (3 messages)

« previous php.bugs (#69069) next »