你好我的代碼有問題,即時通訊嘗試讀取myfile的特定值,如果找到值,它將只從文件中刪除該文本值並繼續。繼承人我得到了:Aut是我有的形式的一部分,如果在文本文件中找到表單中鍵入的值,它將回寫到該文本文件,如果沒有,它將回顯無效令牌。所有的幫助表示讚賞。某些文本的PHP檢查文件
<?php
$myfile = "Variables.txt"; /**This part defines my file holding the keys**/
$lines = file($myfile);
$fn = "DropBox/Dropbox/Public/Licenses.txt"; /**this is where addition/aut are written**/
$file = fopen($fn, "a+");
if(!($fd = fopen("Variables.txt","w")))
die("Could not open $file for writing!");
if(!(flock($fd,LOCK_SH)))
die("Could not equire exclusive lock on $file!");
for($i = 0; $lines[$i]; $i++)
{
if($_POST['Aut'] == rtrim($lines[$i])) /** if the input value in Aut is found in Variables.txt, only that line will be deleted **/
{
fwrite($file, $_POST['addition']."\n\t"); /** writes addition which is an input variable to the file $file **/
fwrite($file, $_POST['Aut']."\n\t"); /** the Aut removed from $myfile is also written to $file **/
}
else
{
echo "Invalid Code"; /** if the codes is invalid, then this is echoed **/
}
}
if(!(flock($fd,LOCK_UN)))
die("Could not release lock on $file!");
if(!(fclose($fd)))
die("Could not close file pointer for $file!");
?>
請解釋你的代碼當前做錯了什麼。 (它看起來像你可以更好地使用數據庫) – mario 2015-02-06 05:30:35
我所有的代碼正在訪問我希望它訪問的文件,但它會自動刪除所有內容,並回顯10次無效的代碼。我不知道如何使用數據庫如何做 – 2015-02-06 05:36:06
嗯,它寫後確認密鑰,所以它的作品,但它刪除我的文件 – 2015-02-06 05:39:08