Advertisement
Kyrremann

$POST example

Mar 10th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. <html>
  2.   <head>
  3.     <title>PHP Get Results</title>
  4.   </head>
  5.   <body>
  6.  
  7.   <?php
  8.  
  9.   // Show all URL parameters (and
  10.   // all form data submitted via the
  11.   // 'get' method)
  12.   $file = "test.txt";
  13.   $fh = fopen($file, 'a') or die("Can't open file");
  14.   fwrite($fh, "Timestamp: " . time() . "\n");
  15.   foreach($_GET as $key=>$value) {
  16.     // echo $key, ' => ', $value, "<br/>\n";
  17.     fwrite($fh, $key . ' => ' . $value . "\n");
  18.  
  19.   }
  20.   fclose($fh);
  21.  
  22.   $fh = fopen($file, 'r');
  23.   $data = array();
  24.   while (!feof($fh)) {
  25.     // echo fgets($fh), "<br />";
  26.     array_push($data, fgets($fh));
  27.   }
  28.   fclose($fh);
  29.  
  30.   for ($i=count($data) - 1; $i > 0 ; $i--) {
  31.     echo $data[$i], "<br />";
  32.   }
  33. /*
  34.   // Show a particular value.
  35.   $id = $_GET['temp'];
  36.  
  37.   if($id) {
  38.     echo '<p/>ID: ', $id, "<br/>\n";
  39.   }
  40.   else {
  41.     echo '<p>No ID parameter.</p>';
  42.   }
  43. */
  44.   ?>
  45.  
  46.   </body>
  47.  
  48. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement