-5

Our requirement is to write the variables to a text file in append mode. This can be only partially achieved by the below coding.

First two variable - vuserid and vworkorder are obtained from $_GET, this can be written on the page using ECHO command, however using fwrite + $_POST it is not getting written to File. All Other Variables that are as per user response on the page can be written to the file.

<?php  

         $f = fopen("textfile.txt", "a");

         fwrite($f, $_POST["vuserid"] );
         fwrite($f, "|"); 
         fwrite($f, $_POST["vworkorder"]); 
         fwrite($f, "|"); 
         fwrite($f, $_POST["Ques1"]); 
         fwrite($f, "|"); 
         fwrite($f, $_POST["Ques2"]); 
         fwrite($f, "|"); 
         fwrite($f, $_POST["Ques3"]); 
         fwrite($f, "|"); 
         fwrite($f, $_POST["Ques4"]); 
         fwrite($f, "|"); 
         fwrite($f, $_POST["q14"]);
         fwrite($f, ";"); 

     // Close the text file
     fclose($f);              

       echo "Thanks for your Response";     

 ?>
Damien Pirsy
  • 25,319
  • 8
  • 70
  • 77
Subhash
  • 11
  • 2
  • Why would `$_POST` work if they are `$_GET` parameters? – Scott Helme Oct 22 '13 at 12:39
  • Can you please provide a bit of code? Not much to do here without a start – DKSan Oct 22 '13 at 12:41
  • Do you understand the difference between `$_GET` and `$_POST`? See [this question](http://stackoverflow.com/questions/504947/when-should-i-use-get-or-post-method-whats-the-difference-between-them?lq=1) for instance – mariusnn Oct 22 '13 at 12:42
  • They are both just variable arrays. Show us the conflicting code so we can deduce your problem – Aayush Agrawal Oct 22 '13 at 12:45

1 Answers1

0

if i understand you correct, you just want put all variables from $_GET to $_POST?

foreach ($_GET as $key => $value) {
    $_POST[$key] = $value;
    unset($_GET[$key]);
}

print "<pre>";
var_dump($_POST);
print "</pre>";

hope it helps... but at all i think there should be another way to get your vars to your file

MAQU
  • 562
  • 2
  • 12
  • Thanks..let me check this option, My Objective is get the data from the URL and then use $_POST to write that into a FILE in append mode... – Subhash Oct 23 '13 at 05:56