-3

I have made a very simple editable html page using content editable But I'm new to using php and want to use it so save the changes to the HTML page. and some way of keeping a history of the page,

I don't even know where to start, But I'm thinking of using echo at the bottom of the page

"last updated : $TIMESTAMP"

and also writing it to some sort of log file

Apologies but it's not an HTML file i'm trying to save it a PHP file but I'm trying to use the below php function that will be called by an html button, to save the current webpage as a new file, but it doesn't even create the new file?

<?php
$SERVER = basename(__FILE__, '.php');
$FILENAME = "$SERVER.php";
function save(){
$file = fopen('test.php','w');
fwrite($file,file_get_contents($FILENAME));
fclose($file);
}
?>
<button onclick="save()">save</button>
user2385338
  • 1
  • 1
  • 2
  • 1
    databases are perfect for this – Peter Apr 13 '17 at 09:54
  • You need to track the changes made to `contenteditable` with JavaScript and then send it (on click of a button or time-based repetition) with Ajax to a PHP page which then stores it in a file or a database. – ssc-hrep3 Apr 13 '17 at 09:57

3 Answers3

0

use file function to create html page, and database entry to keep time stamp of creation this file.

$myfile = fopen("test.html", "w");
D. Pachauri
  • 244
  • 2
  • 8
0

You should open the html file with fopen function with 'r' value and then read all the content from that page and save it in a db . If u want an example i will give u the full code. Just say me.

$open = fopen('your file name','r');
-1

Hei dude I am back with the code.

<?php

$file = fopen('test.txt','w');
fwrite($file,file_get_contents("test.html"));
fclose($file);
 ?>

Explication: so you cant open the html file with php u just can get its full code with file_get_contents("yourpage.html") and then write it in a .txt file. you will open it with the fwrite function which creates the file if doesn't exists and then you will just write the code in that txt file. And u can save that .txt file in a db,if u want to show u how just say me ! Nice Day!