直接上代码:
一、写入和显示已写入文件内容:
<?php
header("Content-type: text/html; charset=utf-8");
$name = "无";
// echo "\n开始\n";
// var_dump($_GET);
//首先看是否传值过来了,如果有就写入文件
if($_POST['name']&&$_POST['type']){
$name = $_POST['name'];
$myfile = fopen("./wxm.txt", "w") or die("Unable to open file!!W");
fwrite($myfile, $name);
fclose($myfile);
}
$type = time();
$myfile = fopen("./wxm.txt", "r") or die("Unable to open file!!R");
$name = fread($myfile, filesize("./wxm.txt"));
fclose($myfile);
// 直接展示当前的数值,可提供提交的form表单
echo "<form action=\"./qiang.php\" method=\"post\" class=\"form-horizontal\" enctype=\"multipart/form-data\">
<label><span style=\"color: red;\">*</span>请输入当前公众号名字:</label>
<input type=\"hidden\" name='type' value=\"".$type."\">
<input type=\"text\" name='name' value=\"".$name."\" placeholder=\"请输入公众号名字\">
<button type=\"submit\" class=\"btn btn-primary\">提交设置</button>
</form>";