Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am storing information from an HTML form (NOT passwords) in a txt file:
Here is the code:
<?php
              
if(isset($_POST['sender']))
{
$data=$_POST['sender'];
$fp = fopen('name.txt', 'a');
fwrite($fp, $data);
fclose($fp);
}
?>

It works alright, but when I put in mutiple input, it does not line break. How would I do that?

What I have tried:

I have tried to put an HTML break tag in but I am not sure what spot to put it in. Please help. I am new to PHP.
Posted
Updated 14-Jul-20 21:16pm

Assuming you mean a line end character in a text file:
PHP
$fp = fopen('name.txt', 'a');
fwrite($fp, $data);
fwrite($fp, "\n"); // NB double quotes must be used here
fclose($fp);
 
Share this answer
 
If you want to add a break in between lines just echo a break element -

PHP
echo "<br />";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900