From:             ssruprai at hotmail dot com
Operating system: Windows 2003, XP
PHP version:      5.2.6
PHP Bug Type:     IIS related
Bug description:  IE / IIS Double form post in case of redirection

Description:
------------
I am facing a strange problem of IE double posting in case of self post. 
PHP 5.2.6 / IIS 5.1 on windows XP.
 
Before starting I must tell you that:
 
It works with firefox, Apache / PHP combination.
It works with IE / Apache / PHP combination
It works with firefox / IIS / PHP Combination
But it DOES NOT work with  IE/PHP/ IIS
 
 This seems to be the case case with all IE versions (specially IE 6) and
it happens on even the windows 2003 server.
 
 I have a form with just one field which uploads a single file and posts 
back to same PHP file. The file is a csv file and it is properly read and
inserted into database. After it is successfully inserted I issue a
redirect to some other page using header("Location:other_page.php"). When
the header is executed the form is posted again.


I know that it was posted twice because when I see the database the
records are inserted twice.

I am not sure if it is IIS, PHP or IE Problem.
 
This is not the first time I have experienced this. I had earlier faced
the similar double post problem in case of self post (WITHOUT USING
REDIRECT header but this seems to have been resolved with latest php ISAPI
version. At that time I just switched to apache as most hosting servers
were linux and there was no problem). 

But now the problem is that production server is Windows 2003 server with
IIS. (The version of PHP IIS or windows shouldn't not matter though)

My application is using all sorts of libraries, from pear db, quickform to

smarty so I have just created a simple upload form . Which does nothing
but logs the access to find out about double 
post.

I had tried many different php versions and all produced same result. I
have created a simple form for testing. If you'll upload a small text file
you'll see 
that there are two entries in log file for one access.

The platform to test is IIS (ISAPI) php 5 and Internet explorer 6.  (IE 7

may not post values twice but it will display some page not found error.)



Reproduce code:
---------------
<?php
set_time_limit ( 300); 

if (@$_POST['submitted'] == 'yes')
{
        $csv_file = $_FILES['csv_file'];
        if ($csv_file['size'] > 0)
        {               
                
                $fp = fopen('access.txt', 'a');
                fwrite($fp, 'Accessed at '. date('d-m-y H:i:s u'). "\r\n");
                fclose($fp);
        
                header('Location:http://www.google.com');
                exit;
                
                /* if instead of above header, javascript redirect is used then 
it is
not posted twice */
                
                /*echo "<script language='javascript'>\n";
                echo "location.replace('http://www.google.com');\n";
                echo "</script>";*/
                                
        }                               
        else if ($csv_file['error'] == UPLOAD_ERR_FORM_SIZE || 
$csv_file['error']
== UPLOAD_ERR_INI_SIZE)
        {
                $error = "File size exceeds max allowed size of whatever";
        
        }
        else
        {
                $error = "There was error in uploading your file.";
        
        }       

}

?>
<html>
<head>
<title>
test
</title>
</head>
<body>
<?php
if (isset($error))
{
        echo "<B>$error</B>";
}
?>
<form method="post" enctype="multipart/form-data">
<input name="MAX_FILE_SIZE" type="hidden" value="5242880" />
<input type="file" name="csv_file" />
<input type="hidden" name="submitted" value="yes" />
<input type="submit" value="Submit" />
</form>
</body>
</html>


-- 
Edit bug report at http://bugs.php.net/?id=45361&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45361&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45361&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45361&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45361&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=45361&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45361&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45361&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45361&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45361&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45361&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=45361&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=45361&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45361&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45361&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45361&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45361&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45361&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45361&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45361&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45361&r=mysqlcfg

Reply via email to