Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP edit file on server?
#2
I can seem to find any reference to the "undefined index: page"...
Code:
<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
    <textarea rows="10" cols="100" name="content"><?php readfile($fn); ?></textarea><br />
    <input type="submit" value="Save" VALUE="Refresh">  
</form>

And yet your script tries to locate it...
PHP Code:
$firstfile =  $_POST['page']; 

Cleared and should work, still not secure though...
Study the script and look at the changes before you just go on copy-pasting...
Code:
<?php

$firstfile =  (isset($_POST['page'])) ? $_POST['page'] : ((isset($_GET['page'])) ? $_GET['page'] : '');
echo $firstfile;   // the file is shown, and is there
$fn = $firstfile; // totally wasting resources and space: lulz


if (isset($_POST['content']))
{    
    $content = stripslashes($_POST['content']);
    $fp = fopen($fn,"w") or die ("Error opening file in write mode!"); // fopen($firstfile) // remove $fn
    fputs($fp,$content);
    
    fclose($fp) or die ("Error closing file!");
}
?>
<form action="<?php echo $_SERVER["PHP_SELF"].'?page={$firstfile}' ?>" method="post">
    <input type="text" name="page" value="{$firstfile}" /><br />
    <textarea rows="10" cols="100" name="content"><?php readfile($fn); ?></textarea><br />
    <input type="submit" value="Save" VALUE="Refresh">  
</form>
Reply


Messages In This Thread
PHP edit file on server? - by Inventor - 10-21-2011, 03:38 PM
RE: PHP edit file on server? - by Gaijin - 10-21-2011, 04:25 PM
RE: PHP edit file on server? - by Inventor - 10-21-2011, 04:57 PM
RE: PHP edit file on server? - by Gaijin - 10-22-2011, 04:24 AM
RE: PHP edit file on server? - by Inventor - 10-22-2011, 07:19 AM
RE: PHP edit file on server? - by saikiran - 08-08-2012, 04:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  PHP Framework List: An Ultimate Guide to 102 PHP Frameworks for Web Developers tk-hassan 0 786 07-27-2020, 11:26 PM
Last Post: tk-hassan
  Use PHP in a text file? Blic 4 1,266 10-25-2011, 08:12 PM
Last Post: Project Evolution
  PHP Video Tutorials (PHP For Beginners) Eleqtriq 4 3,300 10-10-2011, 01:00 PM
Last Post: Greyersting
  help : PHP : Executing .jar file killer_03 0 1,037 03-12-2011, 11:09 PM
Last Post: killer_03
  Common PHP and SQL [File-Sharing Site] Project Evolution 3 1,701 12-12-2010, 02:47 AM
Last Post: Bursihido

Forum Jump:


Users browsing this thread: 1 Guest(s)