-1

I am originally a java programmer but I need a very basic PHP script that will record the text given from the link to a .txt file(or an alternative) .

Such as

In java

String url = http://www.mywebsite.com/recorder.php?=

String stringToRecord = blablabla

String websitetovisit = url + stringToRecord

Then I'd just make the java application inquire that link and the script would add the string after ?= in a txt file.

But I have literally no experience in PHP.

How do I accomplish this? I have tried reading some PHP tutorials but I still don't have the slightest idea about this.

EDIT:

Let's say that there's the website www.mywebsite.com and there's a file in it, recorder.php

What recorder.php does is gets the string IN the link after the ?= and pastes it in a local .txt file.

So basically

www.mywebsite.com/recorder.php?=this_is_a_test

Would parse

this_is_a_test

into a local .txt file.

This is what I am trying to accomplish.

joe dacoolguy
  • 309
  • 2
  • 8
  • 18

4 Answers4

0

Try like this:

$url = "http://www.mywebsite.com/recorder.php?=";

$stringToRecord = "blablabla";

$websitetovisit = url ."". stringToRecord;
$text = file_get_contents($websitetovisit);
file_put_contents('test.txt', $text);

I EDIT CODE

Erman Belegu
  • 4,074
  • 25
  • 39
0
file_put_contents('a.txt', file_get_contents($url));

This is how you should do that.

Kristiono Setyadi
  • 5,635
  • 1
  • 19
  • 29
UnknownError1337
  • 1,222
  • 1
  • 12
  • 16
0

Just copy the following code and paste it in you recorder.php

<?
/*$_GET returns all get parameter as an array.print_r will convert the 
 array to string and file_put_contents will save it to file*/
file_put_contents("text.txt",print_r($_GET,true));
RadhaKrishna
  • 312
  • 3
  • 13
0

If you want to save the query part of the URL as-is (as it looks in the browser's address bar), then you could use:

file_put_contents('query.txt', parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY));
ironcito
  • 807
  • 6
  • 11