0

i'm trying to build a browser extension that reads the "users online counter" on a specific website. I then want my browser extension so send this number to my server (i have my own top domain). I want this number to be saved in an number.html file on the server. I did some research and think that this can be done with a XMLHttpRequest POST request, but i am a beginner in coding and can't get it to work.

xhttp.open("POST", "www.mydomain.com/number.html", false);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send(numbervariable);

Or do i need to point that request to a .php file on my server, that can process the request and save the incoming number in a .html file? I would really appreciate some help what code i need in my browser extension and what needs to be done on my server to process the incoming data. Maybe a .php file like this?

$html=base64_decode(urldecode($_POST['innerHTML']));
file_put_contents(numbers, $html);

I am completely lost...

  • Your variable is not called `innerHTML` – mplungjan Aug 13 '20 at 08:43
  • Welcome to Stack Overflow! Please visit the [help], take the [tour] to see what and [ask]. [Do some research, search for related topics on SO](https://www.google.com/search?q=php+post+xmlhttprequest+parameter+site%3Astackoverflow.com); if you get stuck, post a [mcve] of your attempt, noting input and expected output using the `[<>]` snippet editor. – mplungjan Aug 13 '20 at 08:44

0 Answers0