Jump to content

Recommended Posts

[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.
Link to comment
https://forums.phpfreaks.com/topic/8090-php_self-problem/
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/8090-php_self-problem/#findComment-29522
Share on other sites

@Brendan

php_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.
Link to comment
https://forums.phpfreaks.com/topic/8090-php_self-problem/#findComment-29546
Share on other sites

[!--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--]
@Brendan

php_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?
Link to comment
https://forums.phpfreaks.com/topic/8090-php_self-problem/#findComment-29613
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.