首先php页面打开是一个输入框和一个按钮,
第一次在输入框内输入123,点击按钮后,在网站根目录下生成123.txt,内容为1
第二次再在网页上输入123,点击按钮后,123.txt内容中增加一个1,也就是内容为11
再举个例子
第一次在输入框内输入456,点击按钮后,在网站根目录下生成456.txt,内容为1
第二次再在网页上输入456,点击按钮后,456.txt内容中增加一个1,也就是内容为11帮忙一下应该如何写
第一次在输入框内输入123,点击按钮后,在网站根目录下生成123.txt,内容为1
第二次再在网页上输入123,点击按钮后,123.txt内容中增加一个1,也就是内容为11
再举个例子
第一次在输入框内输入456,点击按钮后,在网站根目录下生成456.txt,内容为1
第二次再在网页上输入456,点击按钮后,456.txt内容中增加一个1,也就是内容为11帮忙一下应该如何写
<html>
<head>
<title></title>
</head>
<body>
<form action="test.php" method="get">
<input type="text" name="filename" />
<input type="submit" value="submit" />
</form>
</body>
</html>
后台test.php
<?php
$a = $_POST['filename'];
$b = $a.'txt';
$handle = fopen($b,"a");
if(fwrite($handle, '1')){
echo "ok";
};
fclose($handle);
<?php
$data = isset($_POST['data'])? $_POST['data'] : '';
if($data){
file_put_contents($data.".txt", 1, FILE_APPEND);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title> 提交 </title>
</head> <body>
<form name="form1" id="myform" method="post" action="">
<p>数据:<textarea name="data"></textarea></p>
<p><input type="submit" name="b1" onclick="fsubmit()" value="提交"></p>
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form action="test.php" method="post">
<input type="text" name="filename" />
<input type="submit" value="submit" />
</form>
</body>
</html><?php
$a = $_POST['filename'];
$b = $a.'.txt';
$handle = fopen($b,"a");
if(fwrite($handle, '1')){
echo "ok";
};
fclose($handle);
<?php // _ooOoo_
// o8888888o
// 88" . "88
// (| -_- |)
// O\ = /O
// ____/`---'\____
// . ' \\| |// `.
// / \\||| : |||// \
// / _||||| -:- |||||- \
// | | \\\ - /// | |
// | \_| ''\---/'' | |
// \ .-\__ `-` ___/-. /
// ___`. .' /--.--\ `. . __
// ."" '< `.___\_<|>_/___.' >'"".
// | | : `- \`.;`\ _ /`;.`/ - ` : | |
// \ \ `-. \_ __\ /__ _/ .-` / /
// ======`-.____`-.___\_____/___.-`____.-'======
// `=---='
//
// .............................................
// 佛祖镇楼 BUG辟易if($name = $_POST['name']){
file_put_contents("$name.txt","1",FILE_APPEND);
}
?>
<form action="./test0722.php" method="post">
<input type="text" name="name"/>
<input type="submit" value="提交"/>
</form>