Hack Forums
[PHP] Log data received at postback? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183)
+---- Thread: [PHP] Log data received at postback? (/showthread.php?tid=5679562)



Log data received at postback? - FaberCastell - Jul 27, 2017

So yeah i entered my site url to the php file as a postback, and these are the instructions

[Image: lSu0Z1a.png]

And i did

$offerid = $_GET['offer_id'];
$offername = $_GET['offer_name'];
$affiliateid = $_GET['affiliate_id'];
$ip = $_GET['ip'];
$ran = $_GET['ran'];

But it's not working... Is there a way i could log what i am receiving and save it as a file? How?


* - Charger - Jul 27, 2017

file_put_contents("log.txt",$data)


* - FaberCastell - Jul 27, 2017

(Jul 27, 2017 06:44 AM)Charger Wrote:  file_put_contents("log.txt",$data)

How do i set $data? Because as i said i tried with those variables, but i don't know what exactly am i getting... how could i log it all that i am getting


* - CodeBinary - Jul 27, 2017

(Jul 27, 2017 09:33 AM)FaberCastell Wrote:  How do i set $data? Because as i said i tried with those variables, but i don't know what exactly am i getting... how could i log it all that i am getting

PHP Code

<?php 
$data 
= $offerid . "\r\n" . $offername  . "\r\n"  . $affiliateid  . "\r\n"  . $ip   . "\r\n"  .  $ran  . "\r\n"; 

Puts each of these variables on a new line use the code posted from charger to add to text file.


* - Vana - Jul 27, 2017

(Jul 27, 2017 12:25 PM)Brian OConner Wrote:  
PHP Code

<?php 
$data 
= $offerid . "/r/n" . $offername  . "/r/n"  . $affiliateid  . "/r/n"  . $ip   . "/r/n"  .  $ran  . "/r/n"; 

Puts each of these variables on a new line use the code posted from charger to add to text file.

Your "/r/n"'s should be "\r\n". Along with that, "\n" is the standard POSIX style so unless you're on Windows you should be using that.


* - CodeBinary - Jul 27, 2017

(Jul 27, 2017 12:29 PM)Vana Wrote:  Your "/r/n"'s should be "\r\n". Along with that, "\n" is the standard POSIX style so unless you're on Windows you should be using that.

O ya my bad im usually using html so I use <br> i don't work with text files much.


* - FaberCastell - Jul 27, 2017

(Jul 27, 2017 12:25 PM)Brian OConner Wrote:  
PHP Code

<?php 
$data 
= $offerid . "\r\n" . $offername  . "\r\n"  . $affiliateid  . "\r\n"  . $ip   . "\r\n"  .  $ran  . "\r\n"; 

Puts each of these variables on a new line use the code posted from charger to add to text file.


what i want is $data = all data that i receive, because i don't know what exactly am i getting, so i can see what i am working with


* - Vana - Jul 27, 2017

(Jul 27, 2017 03:50 PM)FaberCastell Wrote:  what i want is $data = all data that i receive, because i don't know what exactly am i getting, so i can see what i am working with

PHP Code

<?php

$data 
= json_encode($_GET) . "\n";
file_put_contents("log.txt", $data, FILE_APPEND);

?>