PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Not sure what your problem is now as the PHP_SELF thing isn't a problem
The code you posted should work fine (presuming the function does indeed work as you said it does).
i.e doing
is inside the function, so when it posts to itself it doesnt know what to do.
It also wont work if i put it outside of the function because then it doesnt know the filename.
Any ideas?
function file_edit($filename){
global $HTTP_POST_VARS;
if (isset($HTTP_POST_VARS['Submit']))
....
The posting to itself, $_SERVER['PHP_SELF'] isn't an issue as if file1.php includes file2.php, and file2.php does a POST to $_SERVER['PHP_SELF'] it will POST to file1.php as normal. By the way, your script as it is requires register_globals to be On, and they are Off by default in most recent versions of PHP, so might be worth checking that too as your script won't work otherwise.
When it submits, it will never be able to reach that line because that line is WITHIN a function and doesnt get called.
If i put it outside of that function it doesnt know the filename.
I can use a hidden field to remember the filename, maybe i should just try that. That way i should be able to have multiple fields on one page...i think.
This is the way i chose to do it. It works fine and you can have multiple files on 1 web page. Notice the saving is outside of the function. It works good. Thought i would post it if you were interested.