PHP edit file on server? - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21) +---- Thread: PHP edit file on server? (/showthread.php?tid=22799) |
PHP edit file on server? - Inventor - 10-21-2011 Hello, I am getting a error when I use a post variable to edit a file on the server. What I want is to enter the name of the file and then edit it. Here is my code: First file "editor.php" PHP Code: <form action="editpage-2.php" method="post" /> Second file "editpage-2.php" PHP Code: <?php The problem is when I hit the save button, it shows this error: Notice: Undefined index: page in C:\xampp\..\editpage-2.php on line 3 Warning: fopen() [function.fopen]: Filename cannot be empty in C:\xampp...\editpage-2.php on line 11 Error opening file in write mode! Is there any thing that I missed? Thank you all, Inventor RE: PHP edit file on server? - Gaijin - 10-21-2011 I can seem to find any reference to the "undefined index: page"... Code: <form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post"> 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 RE: PHP edit file on server? - Inventor - 10-21-2011 It was not a copy paste. Thank you for helping me! Edit: The page is getting the posted variable from another page "editor.php", not from the current page. $firstfile = $_POST['page']; Is from the post from the editor.php. RE: PHP edit file on server? - Gaijin - 10-22-2011 You have your editor.php, and then you have the line in code; PHP Code: $firstfile = $_POST['page']; The code I posted works as intended too, and if it's not what you want then read about using sessions and checking $_POST. RE: PHP edit file on server? - Inventor - 10-22-2011 Thank you for helping me! I didn't know that I needed a second POST in the second form, thanks! RE: PHP edit file on server? - saikiran - 08-08-2012 for registration form how to send thanks mail to customer who had enter the form details in our site. please help me out |