<!doctype html>
<html>
<body>
<?php
echo "<h3>your order is processed !!!!</h3> <br>";
$akash = $_POST["tires"];
$akash2 = $_POST["Oil"];
$akash3 = $_POST["plugs"];
$akash4 = $_POST["hello"];
$write = "tires is ".$akash."<br>" ."Oil is " .$akash2."\t" ."Spark plug is " .$akash3."\t". "address is " .$akash4."<br>";
$open = fopen("order.txt","ab");
$write = fwrite($open,$write);
?>
</body>
</html>
Asked
Active
Viewed 358 times
0

Unihedron
- 10,902
- 13
- 62
- 72
2 Answers
1
Try /r/n
rather <br>
(it's a html tag will not work with txt)
$write = "tires is ".$akash."\r\n" ."Oil is " .$akash2."\t" ."Spark plug is " .$akash3."\t". "address is " .$akash4."\r\n";
$open = fopen("order.txt","ab");
$write = fwrite($open,$write);
fclose($open);
in my case output is:-
tires is sdff
Oil is ddddd Spark plug is fffff address is ggggg

Rakesh Sharma
- 13,680
- 5
- 37
- 44
-
-
\r - carriage return , \n - newline you need to accept/upvote helpful answers – Rakesh Sharma Sep 07 '14 at 06:49
0
you may want to drop the "b" in the fopen statement. From the manual , option b is "binary" which is probably causing the error.

Keith Grey
- 151
- 7
` is html, if you open the file in browser you will get linebreaks, if you open it in notepad you propably get `tabs`. To linebrake in notepad you need `\n` or better use `\r\n`. Also, its not very important but..., you dont close the handle from `fopen`. And why are you overriding your string with the write-state ? – Dwza Sep 07 '14 at 05:57
Oil is 2 litres Spark plug is 6 address is adam@yahoo.com
This order was processed atSun Sep 2014 this is how my text file looks after i run my code – Akash Devgan Sep 07 '14 at 06:24