Jump to content

The Simpelest of PHP/TXT CMS


bramwolf

Recommended Posts

Hey Guys,

 

I am trying to create a php file that takes a txt file, devides it and shows it in separate text areas.

I have a simple website with 5 pages and I take alot of info for the content from one txt file.

Can you guy help me create a php file that creates a page with multilpe text area's filled with separate

parts of a txt file with updat buttons next to it?

 

examp:

 

*text area*

Welcome to website blah blah blah!                          *button* "Update!"

 

*text area*

On his website you will find blah blah :)                      *button* "Update!"

 

/examp :P

 

I've come so far as to create a text area with the entire file and a update button but can't seem to find out how to chop the file up into different area's:

 

<?php

// set file to read

$filename =$_GET['p'];

 

$newdata = $_POST['newd'];

 

if ($newdata != '') {

 

// open file 

$fw = fopen($filename, 'w') or die('Could not open file!');

// write to file

// added stripslashes to $newdata

$fb = fwrite($fw,stripslashes($newdata)) or die('Could not write 

to file');

// close file

fclose($fw);

}

 

// open file

  $fh = fopen($filename, "r") or die("Could not open file!");

// read file contents

  $data = fread($fh, filesize($filename)) or die("Could not read file!");

// close file

  fclose($fh);

// print file contents

echo "<h3>Contents of File</h3>

<form action='$_SERVER[php_self]' method= 'post' >

<textarea name='newd' cols='100%' rows='50'>$data</textarea>

<input type='submit' value='Change'>

</form>";

 

?>

 

this works great when you enter it like this:

www.website.com/script.php?p=textfile.txt

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/223292-the-simpelest-of-phptxt-cms/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.