html php表单存储结果是一个文本文件

I am using following html, php code. Everything works fine. I can store the html form submitted values to a text file. But when I load the html page I see following when doing tail -f filename.

mytext.txt: file truncated

I looks like when the page loads or is refreshed text file is written with no values. How can I only write the values when submit button is clicked and not write when page loads.

<?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>

Your help is appreciated.

That message is output on stderr like all warning and error messages. You can either drop all the error output:

tail -f file 2> /dev/null

Or to filter out only the error messages that contain truncate:

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

Or with zsh or bash:

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