Jump to content

creating a log of this page please


roldahayes
Go to solution Solved by roldahayes,

Recommended Posts

Hi,

 

I am having an issue with certain browsers not being able to receive the data from a $POST form.

 

Could anyone advise a way of getting it to log what is being passed from the form and place it in a text file  please?

<html>
<body onLoad="document.myForm.submit();">
<form action="https://secure2.epdq.co.uk/cgi-bin/CcxBarclaysEpdq.e" method="post" name="myForm">
            
          <?php  $user_agent = "Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)";?>         
<? foreach($_POST as $i => $v) { ?>
<input type="hidden" name="<?= $i ?>" value="<?= $v ?>" />
<? } ?> 
<input type="submit" value="If you are not automatically redirected, please click here" />
</form>
</body>
</html>
Edited by roldahayes
Link to comment
Share on other sites

  • Solution

Solved,

 

// Open LOG File$log = fopen ("formdata.log" , "a");  // For each value pair, output value to LOG$firstvalue=TRUE;foreach ($_POST as $key => $value)  {if (!$firstvalue) { fwrite($log, ", "); }   // If value is array (multiple select list)// Output array to LOG (elements sep by -)if (is_array($value) ) {$firstelement=TRUE;fwrite ($log, "\" ");foreach ($value as $element) {if (!$firstelement) {fwrite ($log, "-");$firstelement=FALSE;}fwrite ($log,$element); }} else { // Not array, output simple valuefwrite ($log, "\" $value ");$firstvalue=FALSE;} } // Line Feed and Close LOG fwrite ($log, "\n");fclose ($log);

 

Thanks for looking

Link to comment
Share on other sites

Just one last question, how would I be able to get a line break after each output to make it more readable?

 

I'm assuming I need "\n" somewhere in

 

// For each value pair, output value to LOG
$firstvalue=TRUE;
foreach ($_POST as $key => $value)  {
if (!$firstvalue) { fwrite($log, ", ") ; }
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.