gpt4 book ai didi

javascript - html php 表单将结果存储在文本文件中

转载 作者:行者123 更新时间:2023-11-28 07:16:19 32 4
gpt4 key购买 nike

我正在使用以下 html、php 代码。一切正常。我可以将 html 表单提交的值存储到文本文件中。但是当我加载 html 页面时,我在执行 tail -f 文件名时看到以下内容。

mytext.txt: file truncated

我看起来像是在页面加载或刷新时写入没有值的文本文件。我怎样才能只在单击提交按钮时写入值而不是在页面加载时写入。

<?php
$action = $_GET["action"];
$customer = $_POST["customer"];
$ourref = $_POST["ourref"];
$custref = $_POST["custref"];
$comments = $_POST["comments"];
$wipe = $_POST["wipe"];


$data = array($customer, $ourref, $custref, $comments, $wipe);
if($action = "save") {
file_put_contents("mytext.txt", implode(':',$data));
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="main.css">
<title>Customer Information</title>
</head>
<body>
<div class="wipemain">
<h2> Test </h2>
<h3> This information will be used by the data wiping system </h3>
<form action="?action=save" name="myform" method="post">
Enter Customer Name:
<input type=text size=80 name="customer"></br></br>
Enter Our Reference Name:
<input type=text size=76 name="ourref"></br></br>
Enter Customer Reference Number:
<input type=text size=69 name="custref"></br></br>
Comments:
<input type=text size=91 name="comments"></br></br>
Select the Data Wiping Method:
<select name="wipe">
<option value="zero">Default - Quick and Secure - Write Zeros across the spindles</option>
<option value="dod522022m">dod522022m / dod - 7 pass DOD 5220.22-M method</option>
<option value="dodshort">dodshort / dod3pass - 3 pass DOD method</option>
<option value="gutmann">gutmann - Peter Gutmann's Algorithm</option>
<option value="ops2">ops2 - RCMP TSSIT OPS-II</option>
<option value="random">random / prng / stream - PRNG Stream</option>
<option value="zero">zero / quick - Overwrite with zeros</option>
<option value="dod522022m">U.S. Navy Staff Office Publication NAVSO P-5239-26</option>
<option value="gutmann">British HMG Infosec Standard 5, Enhanced Standard</option>
<option value="ops2">New Zealand Government Communications Security Bureau NZSIT 402</option>
<option value="random">Australian Government ICT Security Manual 2014 - Controls</option>


</select>
</br></br>
<input type="submit" size=40 onclick="clicked" value="save">
</form>
</div>
<script type="text/javascript">
/** function clicked() {
if (confirm('Do you wanna to submit? Click here to confirm and close this Window')) {
yourformelement.submit();
} else {
return false;
}
} */
function clicked() {
alert("Successfully Processed - Now you can close this Window job"); }

</script>
</body>
</html>

感谢您的帮助。

最佳答案

该消息像所有警告和错误消息一样在 stderr 上输出。您可以删除所有错误输出:

tail -f file 2> /dev/null

或者只过滤掉包含truncate的错误信息:

(tail -f file 2>&1 >&3 3>&- | grep -v truncated >&2 3>&-) 3>&1

或者使用 zshbash:

tail -f file 2> >(grep -v truncated >&2)

关于javascript - html php 表单将结果存储在文本文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32328458/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com