Jump to content

PHP Write to html file and create breaks.


Nightmare61

Recommended Posts

Okay, so I have...

 

Write .php

<?
if(isset($_POST['write_file'])) {

$name = $_POST['name'];
$suggestion = $_POST['suggestion'];
$fp = fopen("ideas.html", "a");
fputs($fp, "$name\t$suggestion\n");
fclose($fp);
echo 'Thank you, Your suggestion has been submitted';
  } else {
die;
}
?>

 

index.php

<title> W.I.P Ideas </title>
<center>

<form method="POST" action="write.php">
<input type="hidden" name="write_file" value="true">
IRC Nick:
<input type="text" name="name" size="25">
<br>
<textarea name="suggestion" rows=25 cols=40>
</textarea>
<br>
<input type="Submit" name="B1" value="Click To Submit">

 

Okay, I've got this, Now how to I made it so that when it writes to ideas.html it'll write it with <br's> so that I can use

<?php include('/home/benny/public_html/wip/ideas.txt'); ?>

On the index file so that it'll print it out as ideas.txt or ideas.html is...

 

Any help will be a treat, thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/52501-php-write-to-html-file-and-create-breaks/
Share on other sites

Depends on what you're doing.

 

If you're simply going to write it to HTML, you can embbed the <br> tags within your php code.

 

echo "<br>bla bla <br>"

 

If your goal is to replace the \n with <br> then you can run a string replace command to accomplish that.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.