Need Help with PHP Backend
Posted: Mon Jan 24, 2005 12:59 pm
Hey guy, I know <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> all for php, but I am learning through doing. I work with Krome Studio Productions and I kinda need to get this script functioning ASAP for a new site design. If I can get this script working I can have our site done by the end of the week.
Here is what I have going on
I have a Page that we use to update all pages on the site. I want to be able to click a link to dynamically load the content of corrsponding text file into a textarea on a form. We can edit the content in the form, and submit it and it saves the changes to the correct text file. My problem is with my script all changes are hardwired to save to body.txt (home page). the page can be found at http://kromepreview.t35.com/kromehome.php.
Here is the code thus far
Here is what I have going on
I have a Page that we use to update all pages on the site. I want to be able to click a link to dynamically load the content of corrsponding text file into a textarea on a form. We can edit the content in the form, and submit it and it saves the changes to the correct text file. My problem is with my script all changes are hardwired to save to body.txt (home page). the page can be found at http://kromepreview.t35.com/kromehome.php.
Here is the code thus far
Code: Select all
<?php
if ((is_array($_GET)) && isset($_GETї'filename'])) {
$filename = $_GETї'filename'] . '.txt';
$fp = fopen($filename, "r");
$contents = fread($fp, 100000);
fclose($fp);
}
// when the form is submitted, make the edits
if ((is_array($_POST)) && isset($_POSTї'body'])) {
$body = stripslashes($_POSTї'body']);
$handle = fopen('body.txt', 'w');
fwrite($handle, $body);
fclose($handle);
}
?>
<html>
<body>
<a href="kromehome.php?filename=body">Home</a>
<a href="kromehome.php?filename=download">Downloads</a>
<form action="kromehome.php" method="post">
<textarea name="body" cols="32" rows="8">
<?php echo $contents; ?>
</textarea><br />
<input type="submit" name="submit" value="Submit" />
<input type="reset" name="Reset" value="Reset Changes" />
</form>
</body>
</html>