Jump to content


Photo

Bit confused, how should I update a file?


  • Please log in to reply
3 replies to this topic

#1 sesstreets

sesstreets
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 01 September 2006 - 06:02 AM

Im trying to write a script that will:

1. Open a file and display the files content into an editable box.
2. On the press of a submit button, it will update the file.

How do I do this? Ive tried fopen and get_file_contents but neither really works

#2 logu

logu
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 01 September 2006 - 06:06 AM

Can you post u r code

#3 extrovertive

extrovertive
  • Members
  • PipPipPip
  • Advanced Member
  • 235 posts

Posted 01 September 2006 - 06:09 AM

<?php
$file = 'my/path/file';

  if(isset($_POST['submit'])
 {
  $filestring = $_POST['filestring'];
 file_put_contents($file, $filestring);
 }

$filestring = file_get_contents($file);
?>
<form action="" method="post">
<textarea name="filestring">echo $filestring</textarea>
<input type="submit" name="submit" value="Submit">



#4 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 01 September 2006 - 07:04 AM

do you get any erros? or does it just do nothing.. i dont see whats wrong.. hhmm.. i shall look harder :-)
Link shortener with advanced, detailed statistics:

http://tyny.us/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users