0

I've been working on a blogging system and I wish to receive information from external php files for a post's Title and Content, here is my code:

External (Blog Post's Content) File: 03-20-2018-This-Is-A-Test.php

<?php
$Title = 'This is a test!';
$Date = '03-20-2018';
$Content = 'Blog Post&#39;s content!';
?>

Client Side Page For Viewing Blog Posts: Post Home.php

<?php
$Title = '';
$Date = '';
$Content = '';

$GetDate = $_GET['d'];
$GetTitle = $_GET['t'];

$postPath = "Posts/$GetDate"."-"."$GetTitle.php";

$postFile = fopen($postPath,"rt");
$postContent = fgets($postFile,filesize($postPath));
?>

<!--Some HTML-->

<h2><? echo $Title; ?></2>
<b><? echo $Date; ?></b>
<p><? echo $Content; ?></p>

<!--Some More HTML-->

<? fclose($postFile); ?>

Client's Page URL: example.com/Post%20Home.php?d=03-20-2018&t=This-Is-A-Test

Reformatted as: example.com/03-20-2018/This-Is-A-Test


As you can see, I am using GET parameters to call the file that I wish to collect the information from. I have tried using fopen which I wasn't able to get to work. Also include is forbidden with the particular server hosts I am using.

I am open to using file_get_contents if someone is able to help me get it to work.

Note: I have confirmed that my calling URL is correct and I get no errors from my php


So, I am trying to use fopen to collect the data of $Title $Date $Content from the file; 03-20-2018-This-Is-A-Test.php and use that information in the Client Side file; Post Home.php

Cœur
  • 37,241
  • 25
  • 195
  • 267
Nathan Martin
  • 295
  • 1
  • 3
  • 13

1 Answers1

0

I was able to find the answer using require().

Nathan Martin
  • 295
  • 1
  • 3
  • 13