I want to make an html document update with input from a form
The goal is to be able to enter the URL, enter the description, enter the date created and output to a file.
My thoughts are to break the HTML document into pieces, begin.txt newarticle.txt and end.txt
Then piece it back together using fopen and fwrite.
I'm sure there's an easier way, but this is how I'm currently trying to do it.
<html>
<body bgcolor="#FFFFFF>
<H1>Add new Article</h1>
<form action="newarticle.php" method="post">
Paste the link address
<input type="text" name="url">
</br>
Paste the description:
<input type="text" name="description">
</br>
Paste the date article was released:
<input type="text" name="date">
<p>
<input type=submit value="Create Article">
</form>
</body>
</html>
newarticle.php
<?php
$v1 = $_POST["url"]; //You have to get the form data
$v2 = $_POST["description"];
$v3 = $_POST["date"];
$file = fopen('newarticle.txt', 'w+'); //Open your .txt file
ftruncate($file, 0); //Clear the file to 0bit
$content = $v1. PHP_EOL .$v2. PHP_EOL .$v3;
fwrite($file , $content); //Now lets write it in there
fclose($file ); //Finally close our .txt
die(header("Location: ".$_SERVER["HTTP_REFERER"]));
?>
This gives me the output on three separate lines.
How do I have it create a file with content formatted it into an actual piece of code :
<li><a href=$v1>$v2</a></li>
<li>$v3</li>
$content.in front of $v1