[PHP] Re: Processing Form Data /w $_POST
What kind of 'logical' order do you need for the Post array? To clarify: Do you need to write to a file the POST variables passed to the script? Kyle Babich [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have a form (setup.php) that passes values to processSetup.php when they are written into setup.txt. I'm trying to instead of writing every idividual value into setup.txt from setup.php, write a loop that will take as many values as there are in the $_POST array and write them all into a single array in logical order in setup.txt. I'm new to php and can't figure out how to do this. I'm thinking of something like... for ($_POST) { fwrite($setup, /*something to add current $_POST value to the end of an array within $setup*/); } How should I go about this? Thank you, -- Kyle -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Processing Form Data /w $_POST
What kind of 'logical' order do you need for the Post array? To clarify: Do you need to write to a file the POST variables passed to the script? Yes, setup.php - processSetup.php - setup.txt Kyle Babich [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have a form (setup.php) that passes values to processSetup.php when they are written into setup.txt. I'm trying to instead of writing every idividual value into setup.txt from setup.php, write a loop that will take as many values as there are in the $_POST array and write them all into a single array in logical order in setup.txt. I'm new to php and can't figure out how to do this. I'm thinking of something like... for ($_POST) { fwrite($setup, /*something to add current $_POST value to the end of an array within $setup*/); } How should I go about this? Thank you, -- Kyle -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Processing Form Data /w $_POST
$setup_filename = /path/to/file/on/the/server/; $fd = fopen($setup_filename , 'a'); #a for appending to file, w to write from the beginning checkout php.net for more details on fopen $report = ; # #Apply any re-ordering of the Post array here to you 'logical' order # look at the manual for asort, ksort, etc foreach ($HTTP_POST_VARS as $index = $value) { $report = key:.$index. = .$value.\n; } fwrite($fd, $report ); fclose($fd); Kyle Babich [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have a form (setup.php) that passes values to processSetup.php when they are written into setup.txt. I'm trying to instead of writing every idividual value into setup.txt from setup.php, write a loop that will take as many values as there are in the $_POST array and write them all into a single array in logical order in setup.txt. I'm new to php and can't figure out how to do this. I'm thinking of something like... for ($_POST) { fwrite($setup, /*something to add current $_POST value to the end of an array within $setup*/); } How should I go about this? Thank you, -- Kyle -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Processing Form Data /w $_POST
Hi, $report = key:.$index. = .$value.\n; actually, shouldn't it be: $report .= key:.$index. = .$value.\n; If you don't have the . there, its going to keep overwriting the report, and thus writing only the last $report item that was built. .= would concat 'em all together. Am I misunderstanding? -Dan Joseph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Processing Form Data /w $_POST
Yes that's right. this was just from the top of my head and it's early for me. it should be $report .= key:.$index. = .$value.\n; as Dan has pointed out. Dan Joseph [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, $report = key:.$index. = .$value.\n; actually, shouldn't it be: $report .= key:.$index. = .$value.\n; If you don't have the . there, its going to keep overwriting the report, and thus writing only the last $report item that was built. .= would concat 'em all together. Am I misunderstanding? -Dan Joseph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php