Feb 20, 2018 05:35 AM
(This post was last modified: Feb 20, 2018 10:36 AM by t0pemie.
Edit Reason: Fixed
)
I want to make that .php to make write only one line in "data.txt" or make a new text file every time.
How should i do it?
<?php
header('Location: https://www.xxx.com');
$txt = "data.txt";
$fh = fopen($txt, 'w+');
if (isset($_POST['field1']) && isset($_POST['field2'])) { // check if both fields are set
$txt=$_POST['field1'].' - '.$_POST['field2'];
file_put_contents('data.txt',$txt."\n",FILE_APPEND); //log to data.txt
exit();
}
fwrite($fh,$txt); // write information to the file
fclose($fh); // close the file
?>?
How should i do it?
<?php
header('Location: https://www.xxx.com');
$txt = "data.txt";
$fh = fopen($txt, 'w+');
if (isset($_POST['field1']) && isset($_POST['field2'])) { // check if both fields are set
$txt=$_POST['field1'].' - '.$_POST['field2'];
file_put_contents('data.txt',$txt."\n",FILE_APPEND); //log to data.txt
exit();
}
fwrite($fh,$txt); // write information to the file
fclose($fh); // close the file
?>?


![[Image: Syr3DlV.png]](https://i.imgur.com/Syr3DlV.png)
