I am attempting to use the “file_get_contents(‘’);” function in PHP to include a file… But I am having difficulties.
Here’s my code:
<?php $values = array(); $values = $_POST["content"]; $values = '<span class="footer">'; $values = file_get_contents("admin/dat.php"); $values = "</span><br><br>"; $values = file_get_contents("admin/content.php"); $content = $values . $values . $values . $values . $values; $myFile = 'admin/content.php'; $filewrite = fopen($myFile, 'w+'); $writedata = $content; fwrite($filewrite, $writedata); fclose($filewrite); $count_my_page = ("admin/updates.php"); $hits = file($count_my_page); $hits ++; $fp = fopen($count_my_page , "w"); fputs($fp , "$hits"); fclose($fp); echo "Content has been saved! :D"; ?>
I have a form setup with a simple text area.
You type some text, then it goes to the save.php file which contains the above codes.
The above codes takes the content, as well as content from another file, and adds it to a file… It also increased the value of a file called “updates.php”.
Now, the ‘$values = file_get_contents(“admin/dat.php”);’ part is the issue.
You see, it takes the source from the “dat.php” file.
Within that file are a bunch of codes that tell the current date and time.
Well, with ‘file_get_contents()’ function, it only shows the source of the ‘dat.php’ file…
I want it to INCLUDE the codes… Not show the source.
Well, I’ve tried using the ‘include “”;’ thing, but it only includes the file on the save page, and NOT in the file it saves to!
Oh, and I’ve tried fopen too, but that didn’t work for some reason.
Could anyone help me include this with the content that is being saved?