Jump to content


Photo

Updateing a php file via another php file


  • Please log in to reply
4 replies to this topic

#1 Rawns

Rawns
  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationUK

Posted 27 April 2006 - 08:05 PM

Ive createad a php file called index.php in a secure folder on my server. On the page is a text area called "textarea" and an update button called "update". When the page opens I want a main news file called mainnews.php to automaticly open into the text area so I can update it online. How would I go about doing this?

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 27 April 2006 - 08:10 PM

Use file_get_contents or fopen, for example:
<?php

$file = file_get_contents("mainnews.php");

echo '<textarea name="textarea">' . $file . '</textarea>';

?>


#3 Rawns

Rawns
  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationUK

Posted 27 April 2006 - 09:21 PM

[!--quoteo(post=369342:date=Apr 27 2006, 09:10 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 27 2006, 09:10 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Use file_get_contents or fopen, for example:
<?php

$file = file_get_contents("mainnews.php");

echo '<textarea name="textarea">' . $file . '</textarea>';

?>
[/quote]

Works fine! Thank you :)

#4 Rawns

Rawns
  • Members
  • PipPip
  • Member
  • 10 posts
  • LocationUK

Posted 27 April 2006 - 09:33 PM

Actually, I just noticed, it 'kind of works' fine. It displays only part of the file. It does not display the PHP tages or any of the print" "; tags, just the HTML.

Whay is this?

#5 Daniel.Conaghan1

Daniel.Conaghan1
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 28 April 2006 - 12:25 PM


$file = file_get_contents("mainnews.php");

echo '<textarea name="textarea">" ' . $file . ' "</textarea>';


You may find extra quotation marks work.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users