将php中的输入数据保存到notepad.txt

<form id="form" name="form" method="post" action="">
    <div class="jquery-script-clear"></div>
    <h1>BARCODE GENERATOR</h1>
    <div id="generator"> Please fill in the code :
        <input  type="text" name="barcodeValue" id="barcodeValue" value="1234"><br>    <br>
    </div>

    <div id="submit">
        <input type="button" onclick="generateBarcode();"     value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Generate &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;">         <input type="button" onclick="printDiv('print')" value="Print" />
    </div>
</form>

<?php
$barcodeValue = $_POST["barcodeValue"];
$save = file_get_contents("save.txt");
$save = "$barcodeValue" . $save;
file_put_contents("save.txt", $save);
echo $save;
?>

sample picture

How to save the input data in save.txt file. When i clicked generate button the text file not showing in same folder.

The problem with your code is you have no submit button so your form was not actually posting when you pressed the button. if you look at my edits you can see I changed the button from input type="button" to type="submit". That allows for the form to submit back to the same php script.

Your script also was causing errors because you accessed $_POST["barcodeValue"] without checking if it existed. You also have to check if the save.txt exists before reading from it. If analyze my edits you can see how checking if the variables are available will help quite a bit.

<form id="form" name="form" method="post" action="">
    <div class="jquery-script-clear"></div>
    <h1>BARCODE GENERATOR</h1>
    <div id="generator"> Please fill in the code :
        <input  type="text" name="barcodeValue" id="barcodeValue" value="1234"><br>    <br>
    </div>

    <div id="submit">
        <input type="submit"   value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Generate &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;">
    </div>
</form>

<?php


    if(isset($_POST["barcodeValue"]))
    {
        $barcodeValue = $_POST["barcodeValue"];
        if(file_exists("save.txt"))
            $save = file_get_contents("save.txt");
        else
            $save = "";
        $save = $barcodeValue . $save;
        file_put_contents("save.txt", $save);
        echo $save;
    }


?>

Let me know if you need more help