What I want is to call for instance /?Hello and then the PHP program to upload "Hello" to the textfile.
<?php
$sqldata = array (serialize($_REQUEST), $_SERVER['PHP_AUTH_USER']);
file_put_contents('textfile.txt', $sqldata);
?>
If this is called, it comes out like this:
a:7:
{
s:4:"Hello";
s:0:"";
s:8:"__cfduid";
s:43:"d1e090c0f439f6aa6bad2e7b18dd9dc701473462630";
s:9:"PHPSESSID";
s:32:"6d602111da31b9a1646fa11d3c3c7e72";
s:8:"cvo_sid1";s:12:"KTVET3PF62UB";
s:9:"utag_main";
s:197:"v_id:0157856889ad001e67d2f49d3db10206d006e06500918$_sn:1$_ss:0$_pn:2;exp-session$_st:1475413904309$ses_id:1475412003245;exp-session$dc_visit:1$dc_event:2;exp-session$dc_region:eu-west-1;exp-session";
s:8:"cvo_tid1";
s:38:"Bkbwvk_D0Uc|1475412341|1475412443|-337";
s:12:"cf_clearance";
s:60:"20d986c985fb1cbab15f286ed34cc09d79c7fb06-1475683723-31536000";
}
I then tried this, hoping it would take out only the part that says "Hello"
<?php
$sqldata = array (serialize($_REQUEST), $_SERVER['PHP_AUTH_USER']);
$myarray[array ]['4'];
file_put_contents('textfile.txt', $myarray);
?>
My end objective, is to request something just like /?Hello and have just that uploaded to the text file.
What you are doing when you request a page with just ?Hello
is actually setting the key "Hello" without a content, which would be the same as ?Hello=
You can test for this by using the following code:
<?php
if ( isset($_REQUEST['Hello']) ) {
// Write stuff to the file.
}
If you don't want it to be triggered when a POST
variable Hello
is present, change the $_REQUEST
to a $_GET
I am assuming that you do not know the exact key in advance and "Hello" can actually be anything.
In that case, you can use array_keys()
to access keys of any array. So in this case, you want to access keys of $_GET
. so something like:
$arrKeys = array_keys($_GET)
will give you all the keys. You can then save them to a file.