Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用txt文件作为测验答案日志(php)_Php_Mysql - Fatal编程技术网

使用txt文件作为测验答案日志(php)

使用txt文件作为测验答案日志(php),php,mysql,Php,Mysql,我有一个写入txt文件的php文件: <?php $answers = "answers.txt"; $fh = fopen($answers, 'a+') or die("can't open file"); $stringData = $_POST["username"]; $timestamp = date("g:i A, m/j/Y"); fwrite($fh, $stringData); fwrite($fh, " started the quiz at "); fwrite($

我有一个写入txt文件的php文件:

<?php
$answers = "answers.txt";
$fh = fopen($answers, 'a+') or die("can't open file");
$stringData = $_POST["username"];
$timestamp = date("g:i A, m/j/Y");
fwrite($fh, $stringData);
fwrite($fh, " started the quiz at ");
fwrite($fh, $timestamp);
fwrite($fh, "\n");
fclose($fh);
?>

我认为MySQL将是更好的选择

从这里开始:

也可以在这里查看其他帖子:

编辑:


别忘了安全

你应该使用db来完成这个任务。@Dagon有没有关于如何设置/使用db的好教程?我的服务器上有phpMyAdmin和MySQL,但我不知道如何有效地创建和使用数据库。谢谢你的回复!互联网上有大量的PHP/MySQL教程。使用搜索引擎。很抱歉,我们无法在这里单独介绍您的基本知识,请尝试使用最适合您的方法加快速度。另一个很棒的页面(也是w3)是:这几乎正是我最终想要的。。。非常感谢您快速而有用的回复!如果这有帮助或是正确答案,请将其标记为正确答案,谢谢!