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.PHP點擊後<a href> content in text file is deleted
My code first page:
<?php
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">
</form>
<a href="get-key3.php" target="_blank">take token</a>';
?>
And the page test.php :
<?php
file_put_contents("cles.txt",$_POST["ak"]."\n".$_POST["as"]);
require_once('OvhApi.php');
[email protected]$_GET["action"];
$ovh = new OvhApi();
$resp = array();
echo '<a href="test.php?action=1">info</a><br>
<a href="test.php?action=2">domain</a><br>';
switch($action)
{
case 1:
$resp = $ovh->get('/me');
var_dump($resp);
break;
case 2:
$resp = $ovh->get('/domain');
var_dump($resp);
break;
}
?>
Thank's for your help.
如果你有你的表單上的方法發佈,那麼你如何獲得GET變量? –
爲了在會話中傳遞變量,您需要在每個頁面上使用session_start()。 –
這不是你的主要問題,但請取出壞和不需要的'fclose(「cles.txt」);'。 –