Brendan Posted April 21, 2006 Share Posted April 21, 2006 [b]SOLVED[/b]OK, i have a script with a form in it, form.php, included in a file with the layout and everything, index.php.Now say i want to put action="<?php print $_SERVER['PHP_SELF'] ?>" in the form, so that when i click submit the form submits the information to its self.The problem is that the form submits to the file its included in, index.php, instead of to its self, form.php. So when i want it to be action="form.php" it ends up being action="index.php" instead. Quote Link to comment https://forums.phpfreaks.com/topic/8090-php_self-problem/ Share on other sites More sharing options...
Ninjakreborn Posted April 22, 2006 Share Posted April 22, 2006 it's generally best when doing forms, unless there really small, actually it's best always to use an external php file to send the information to, you can do it, and there is an explanation of how at[a href=\"http://www.hudzilla.org/phpbook/\" target=\"_blank\"]http://www.hudzilla.org/phpbook/[/a]under the chapter html forms, just skim over that and you can find all the answers you need, but generally you want the file to send to an external file. Quote Link to comment https://forums.phpfreaks.com/topic/8090-php_self-problem/#findComment-29522 Share on other sites More sharing options...
AndyB Posted April 22, 2006 Share Posted April 22, 2006 @Brendanphp_self points to the generated file (includes included) so that in your case the form points correctly to index.php not to the originally included form.php code. If you think of include as equivalent to the server doing a copy/paste of the include into the file called you'll see why index.php is the real 'self'. If you want/need form.php as a standalone script that can submit on itself, you'll need form.php as a separate file which is not included but accessed by link. Quote Link to comment https://forums.phpfreaks.com/topic/8090-php_self-problem/#findComment-29546 Share on other sites More sharing options...
Brendan Posted April 22, 2006 Author Share Posted April 22, 2006 [!--quoteo(post=367410:date=Apr 21 2006, 11:02 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Apr 21 2006, 11:02 PM) [snapback]367410[/snapback][/div][div class=\'quotemain\'][!--quotec--]@Brendanphp_self points to the generated file (includes included) so that in your case the form points correctly to index.php not to the originally included form.php code. If you think of include as equivalent to the server doing a copy/paste of the include into the file called you'll see why index.php is the real 'self'. If you want/need form.php as a standalone script that can submit on itself, you'll need form.php as a separate file which is not included but accessed by link.[/quote]So then i'm assuming there isn't a function that will return the script filename where the function is used? If not, then how would i go about including it as a seperate link, while still being imbedded in the current page? Quote Link to comment https://forums.phpfreaks.com/topic/8090-php_self-problem/#findComment-29613 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.