你好我的代码有问题,即时通讯尝试读取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