AdrienG AdrienG - 1 year ago 117
PHP Question

PHP after a click on <a href> content in text file is deleted

I have a problem : I want to store variable in every pages of my project, but each time I click on a link in my page, the folder is cleaning.
I also try with session variable but it's the same.

My code first page:


echo '
<form action"test.php" method="post">
clé ak : <input type="text" name="ak" /><br><br>
clé as : <input type="text" name ="as" />
<input type="submit" value="submit">
<a href="get-key3.php" target="_blank">take token</a>';

And the page test.php :



$ovh = new OvhApi();
$resp = array();

echo '<a href="test.php?action=1">info</a><br>
<a href="test.php?action=2">domain</a><br>';
case 1:
$resp = $ovh->get('/me');
case 2:
$resp = $ovh->get('/domain');

Thank's for your help.

Answer Source

As a beginner I'm not sure if this will be usefull to you, but I have been playing with text-files as well.

$myfile = fopen("cles.txt", "a+") or die("Unable to open file!");
$ak = $_POST['ak']."\r\n";
fwrite($myfile, $ak);
$as = $_POST['as']."\r\n";
fwrite($myfile, $as);

"a+" here stands for: Open for reading and writing; If the file does not exist, attempt to create it. Writes are always appended. There are other options with fopen(); function.

The source I used was:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download