Tilted Forum Project Discussion Community

Tilted Forum Project Discussion Community (https://thetfp.com/tfp/)
-   Tilted Technology (https://thetfp.com/tfp/tilted-technology/)
-   -   [php]File editor errors... (https://thetfp.com/tfp/tilted-technology/72451-php-file-editor-errors.html)

j0hnb 10-13-2004 10:05 AM

[php]File editor errors...
 
I'm having a problem with this php file editor... It will open a text file correctly but whatever I change to it isn't saved. Where did I go wrong on this code. There is a working example here.

http://www.coolgrindz.com/newsite/editor.php

PHP Code:

<?php
$save 
$_GET['save'];
$file $_GET['file'];
if (empty(
$save)) {
    if(
file_exists($file))
     {    
    
$fp fopen($file "r");
    
$content fread($fpfilesize($file));
    
$content ereg_replace("<""<"$content);
    
$content ereg_replace(">"">"$content);
    
fclose($fp);
    }
    
?>
    <form method="post" action="<?php echo $_SERVER['PHP_SELF'?>">
    File: <input type="text" name="file" value="<?php echo $file?>" class="border" /><br />
    Content:<br />
    <textarea NOWRAP rows="15" cols="90" name="content" class="border"><?php echo $content?></textarea><br>
    <input name="save" type="submit" value="Save" class="button"><input type="reset" value="Clear" class="button">
    </form>
    <?php
}
else {
    
$content ereg_replace("<""<"$content);
    
$content ereg_replace(">"">"$content);
    
$content stripslashes($content);
    
$fp fopen($file "w");
    
fwrite($fp$content);
    
fclose($fp);
}
?>


SinisterMotives 10-13-2004 10:28 AM

It looks like you're querying the $_GET array when the form method is POST. Try querying $_POST['save'], $_POST['file'], etc. The file permissions must be set appropriately on *nix systems too.


All times are GMT -8. The time now is 03:36 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43