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[0] = $_POST["content"];
$values[1] = '<span class="footer">';
$values[2] = file_get_contents("admin/dat.php");
$values[3] = "</span><br><br>";
$values[4] = file_get_contents("admin/content.php");
$content = $values[0] . $values[1] . $values[2] . $values[3] . $values[4];
$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[0] ++;
$fp = fopen($count_my_page , "w");
fputs($fp , "$hits[0]");
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[2] = 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?
Thank you,
Eric