i want to create a php blog system without database

Question

i am creating an blog system where i can use only static files . I have section where i am creating a new post and i write it on a text file like this:

new_post. php

<form id=" form1" name="form1" method="post" action="writeblog.php">
<p> 
<label>TITLE: </label><input type="text" name="title"/>
<label for="body"> Body: </label>
 <textarea name="body" cols=50 rows=10></textarea>
 <br />
 <input type="submit" name="submit" value="POST"/>
 </form>

writeblog.php

<?php
$out = fopen("blog.txt","a");
if(!$out){
header('Location: new_post.php');
exit;
}

$title=$_POST[title];
$body=$_POST[body];
$body=str_replace("\n"," ",$body);
fputs($out,"\n");
fputs($out,date("m/j/y h:i \n ",time()));
fputs($out,"$title\n\n\n");
fputs($out,"$body\n\n\n\n\n");
fclose($out);
header('Location: new_post.php');
exit;
?>

I need some help with how I can work with just one post from the file delete it or edit it insert in on page.


Show source
| php   | html   | css   | xml   2017-01-04 00:01 0 Answers

Answers ( 0 )

◀ Go back