Jump to content

How to include a file in a lower directory?


OneEyedWillie

Recommended Posts

Hello,

 

I've got what should be a simple solution here. I've tried many things but it just won't work for me.

 

This is what I have.

 

I've got a wysiwyg editor setup to write to a file called news.php. The file that has the editor is edit/index.php. It's just a simple textarea. The textarea is supposed to include news.php. For some reason, it won't let me include that file that is in a lower directory. The file that writes to news.php is called edit/write.php. edit/write.php doesn't write to news.php instead it writes to edit/news.php. The only reason I want to include the lower directory is so that I can put a .htaccess password protection on the edit directory. I'll include some code below.

 


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<title>Editing News</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>

<script type="text/javascript" src="nicEdit.js"></script>
<script type="text/javascript">
bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });
</script>

<form method="post" action="write.php">
        <p>     
                <textarea name="content" style="width:100%;height:1000px;"><?php include '../news.php';?></textarea>
                <input type="submit" value="Save" />
        </p>
</form>

</body>
</html>

 


<?php 
$File = "../news.php"; 
$Handle = fopen($File, 'w');
$Data = $_POST['content']; 
fwrite($Handle, $Data);  
fclose($Handle); 
header("Location: index.php");
?>

 

index.php is just a simple include news.php.

 

Am I missing an easy step? Any help would be great!!

Thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.