Log in

View Full Version : How to php get file



MrEnder
01-25-2010, 08:57 PM
Ok I am working on a template for my template I need to be able to change the body to different things without having to reload the whole template over and over again so I have it designed to do exactly that.

One problem though

I need to figure out how to use PHP to be able to get a html/txt document/file and place it in the template when I click on a button

for example

<html>
<head>

<title></title>
<css />

</head>
<body>
<div>Some PHP here to import stuff here from separate file</div>
<button />
</body>
</html>

Ok here is exactly what I'm working with

function windowOpen() {

document.styleSheets[9].disabled = false;
document.getElementById("bodyInnerDiv").innerHTML = '';
e.style.filter = "alpha(opacity=" + (0*100) + ")";
e.style.opacity = 0;

si = setInterval(function() {

io+=0.05;

e.style.filter = "alpha(opacity=" + (io*100) + ")";
e.style.opacity = io;

}, 100);

io = 0;

}

function openDocs() {

windowOpen();
document.getElementById("windowDiv").innerHTML = '<input type="button" value="X" id="XButtonId" class="XButtonClass" onclick="showDesktop()" /> ' + userName + '\'s Documents<hr /><span class="bodyClass">Documents YAY!!!<?php$ file=fopen("test.txt","r"); ?></span>';

}

http://opentech.durhamcollege.ca/~intn2201/brittains/haley/

What would be a script for that and what would it be called? I'm not very good with PHP I'm more of a javascript kinda guy (I've never needed a database before) but I'm trying to go a little further on a personal project and implement some AJAX ideas

So any help anyone?

Thanks
Shelby

MrEnder
01-25-2010, 10:24 PM
Ok I found this

<html>
<body>

<div class="leftmenu">
<?php include("menu.php"); ?>
</div>

<h1>Welcome to my home page.</h1>
<p>Some text.</p>

</body>
</html>

I've seen lots of examples of it I have PHP on my PC and my Server I'm running it through apache but even that does not want to work =[

I'm so confused =[

MrEnder
01-25-2010, 11:05 PM
Ok awesome I figured it out ^.^

I needed to name both files .php for php to work ^.^