lau Posted April 29, 2008 Share Posted April 29, 2008 Ok I have an online survey with 4/5 pages. PHP code saves the data to a text file. In IE this works fine but in Mozilla Firefox no data is saved from the first page, however, all the data is saved from the subsequent pages. Does anyone know why this might be? Link to comment https://forums.phpfreaks.com/topic/103372-php-data-saves-from-ie-but-not-from-mozilla/ Share on other sites More sharing options...
lau Posted April 29, 2008 Author Share Posted April 29, 2008 this is the php code from the page where nothing is saved, it is the same for all the pages: <?php foreach ($_POST as $key => $val) { echo '<input type="hidden" name="' . $key . '" value="' . $val . '" />' . "\r\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/103372-php-data-saves-from-ie-but-not-from-mozilla/#findComment-529391 Share on other sites More sharing options...
lau Posted April 29, 2008 Author Share Posted April 29, 2008 sorry the code that actually saves the data is on the last page it is: <?php $File = "Results.txt"; $Handle = fopen($File, 'a'); foreach ($_POST as $key => $val) { //fwrite ($Handle, $val); fwrite ( $Handle, $val. "," ); } fclose($Handle); ?> Link to comment https://forums.phpfreaks.com/topic/103372-php-data-saves-from-ie-but-not-from-mozilla/#findComment-529407 Share on other sites More sharing options...
haku Posted April 29, 2008 Share Posted April 29, 2008 view the source (view -> page source) on each page and see if the hidden fields are being populated with the necessary information. Link to comment https://forums.phpfreaks.com/topic/103372-php-data-saves-from-ie-but-not-from-mozilla/#findComment-529439 Share on other sites More sharing options...
kenrbnsn Posted April 29, 2008 Share Posted April 29, 2008 Can you post the code that creates the forms? Also, I think, it would be much cleaner to save the information in a SESSION. At the top of each processing script, put: <?php session_start(); ?> The instead of the code that generates the hidden input fields, do: <?php foreach ($_POST as $key => $val) if ($key != 'submit') // or whatever your submit button is named $_SESSION['hidden'][$key] = $val; ?> In the last script where you save the information: <?php foreach ($_POST as $key => $val) if ($key != 'submit') // or whatever your submit button is named $_SESSION['hidden'][$key] = $val; $File = "Results.txt"; $Handle = fopen($File, 'a'); fwrite($Handle, implode(',',$_SESSION['hidden'] . "\r\n"); //this way you don't have a trailing comma after all the values fclose($Handle); ?> Ken Link to comment https://forums.phpfreaks.com/topic/103372-php-data-saves-from-ie-but-not-from-mozilla/#findComment-529442 Share on other sites More sharing options...
PFMaBiSmAd Posted April 29, 2008 Share Posted April 29, 2008 If HTML works in one browser and not another, it is likely that the HTML markup is invalid and one browser ignores the invalid HTML while the other browser does not. Copy and paste the "view source" of your form. Link to comment https://forums.phpfreaks.com/topic/103372-php-data-saves-from-ie-but-not-from-mozilla/#findComment-529469 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.