PHP_SELF için POST Odd PHP header () davranış - ortamlarında tutarsız

0 Cevap php

Ben PHP_SELF bir HTML formu POST bir tepki olarak başlık (konum :) geri gönderme ile ilgili bir sorun yaşıyorum.

Kullanım davanın temel parçaları:

  • I'm including inside the main page, a page which contains all of the form UI echoed out. This form POSTs to itself ($_SERVER['PHP_SELF']).
  • This form contains a "file" field and passes some text (login, password, etc) to itself to do an FTP upload.
  • If the upload is successful, I output header() where location is the main page (along with some parameters which tells the containing page to print a successful upload message).
  • The main page (upon receiving the header) should display the include with the form echoed out again for the next upload.
  • Everything works just as expected in Dev, but in Prod, I never get my form back - it's like the header isn't getting sent.

Bu yüzden gizemli yapmış üç şey:

  • I have two environments, dev is windows/apache 1.3.37/php 5.2.11 fast cgi, prod is linux/apache (2.2.16)/php 5.2.14 fast cgi, and I've configured as much of the relevant looking PHP params the same across both dev and prod. In Dev, the aforementioned use case works great. In Prod, the file does upload, but it's as though the header is not getting sent back. The block where the included content should be is completely empty.
  • If I separate the include so that the form content (the UI stuff) is the only thing in the include, and the form POSTs to a separate file which contains the FTP upload logic, the header sent back at the completion of a successful upload does work in both dev and prod...the file uploads, the header gets sent back, the main page refreshes, and the contents of the include are displayed.
  • In Dev, through Fiddler, I can see the POST to PHP_SELF with all the form content, and I clearly see the header returned back. In Prod, I can see the POST to PHP_SELF, everything looks good, but there is never a header returned returned back. However, in debugging, headers_sent told me the header was being sent to the right location. Echo'ing headers_sent shows up in my main page.

Ekstra trivia:

  • I thought at first, .htaccess was getting in the way, but again, everything works if I split out the UI and FTP upload stuff, and .htaccess in this environment is very basic.
  • I also thought, maybe output buffering would change the behavior - I tried ob_start in a variety of logical places, behavior never changed.
  • Lastly, I tried a number options in header location - in some cases, just pointing to http://www.google.com - still it's as though no header is being sent at all.

Ben fikir yokum - Birisi bu yön sunabilir?

En azından şimdi tutarlı yüzden ilginç, eşya gibi dev aynı şekilde davranır, - İşte basitleştirilmiş bir test niteliği taşıyor.

  • Dnm.php işlenmiş bir çift düğme ile "upload.php" adlı bir sayfa dahil edilir.
  • "Try" POSTs to PHP_SELF and the rendered contents of test.php never come back when header('Location: ./upload.php') is called...the space in the including page is blank.
  • However, "Try2" POSTs to test2.php which calls header('Location: ./upload.php') and re-renders the buttons of the included test.php page no problem.

İşte dnm.php olduğunu:

<?php
if($_POST['submit']) {
Header('Location: ./upload.php');
} else {
echo
'<form name="test" action="'.htmlentities($_SERVER['PHP_SELF']).'" method="POST">
<input type=submit value=try name=submit>
</form>
<form name="test2" action="test2.php" method="POST">
<input type=submit value=try2 name=submit>
</form>';
}
?>

ve burada ... dnm.php oldukça basittir.

<?php
Header('Location: ./upload.php');
?>

ve buradan upload.php bir parçası olduğunu:

<!--    <div id="flashcontent"></div> -->
</fieldset><?php require_once('test.php'); ?></div></div>
</body>
</html>

Bugünün güncelleme - Ben başlangıçta düşündüğüm gibi aslında, basit bir test davanın bir davranış değildi. Zaten basit bir test durumda yukarıda gerçek hayat dosya dahil oldu ben klasik başlıklar-zaten gönderildi sorun meydana düşünüyorum hangi içerir. Ben gerçek hayatta dosyası üzerinden yorumladı sonra, basit bir test davanın davranışı şimdi bu yazının başında özetlenen orijinal halinde eşleşir. Yani, basit bir test durumda formda teslim sayılabilir içinde denir eğer başlığını yükler, ve dahil dosyadan yayınlanmıştır-başka bir sayfa çağrıldığında başlığını ... hiçbir sorun yükler. Ancak, üretim, başlık arama sonuçları sadece yayınlanmıştır-bir sayfa çağrıldığında gerçekleşen ve PHP_SELF sorarken denir değilse vardır.

<div class="panel_wrapper">
<div id="general_panel" class="panel currentmod">
<fieldset>
<legend><?php echo TB_UPLOADFILES; ?></legend>
<?php
//define('upload_opt',TRUE);
//require_once('upload_opt.php');
?>
<!--    <div id="flashcontent"></div> -->
</fieldset><?php require_once('test.php'); ?></div></div>
</body>
</html>

0 Cevap