/    Sign up×
Community /Pin to ProfileBookmark

$_SERVER WITH url vars

I want a form to be processed on the same page that its on, but $_SERVER[‘PHP_SELF’] doesn’t recall the page with all the url vars in it. is there a way to do this?

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@gameguy43authorApr 02.2006 — heres my system, i haven't written much of it yet, so by all means if you see anything that could be improved, tell me:

the project:

a website where people can post/upload and view art pieces, like deviantart

the pages in question:

view.php and list.php

list.php has input fields to search for pieces by a specific artist, by a specfic format or genre, etc

view.php shows the piece

now, this may be more trouble than it's worth, but I want the view page to keep the list page's search info (maybe url vars isnt the best idea for this?). using this, I will put a "next" button that will call the list page again to find the next item in the search query and and send the user back to the view page, again with the search info stored somehow.

I would like for thisto work with cookiesturned off

now, the reason i'm workingon this right now is I want a user login system aswell. Again, tell me if you know of a better system for this than I do, but I decided to just put all of the login and logout stuff in the header file, even the form. Thus, the "log in" link calls $_SERVER['PHP_SELF'] and the header reloads the page, but with the log in form at the top. this form again calls the page its on and logs you in.

BUT WHAT IF you want to log in while viewing a piece after doing a search query from the list page. now when you hit the log in link, the page calls itself with a url var telling it to give you the login form, but NOT with the other url vars containing the search query info.

Thus i want to add the action=login url var IN ADITION to the other url vars

yet again, please tell me how this can be done better. If you have done something similar before, please help me out. I always get about this far in a project and end up dying because it just gets too complicated!
Copy linkTweet thisAlerts:
@balloonbuffoonApr 02.2006 — To get the page name with the url variables you can either use this:
[code=php]$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"];[/code]
or this:
[code=php]$_SERVER["REQUEST_URI"];[/code]
The second option I have found to not be available in some cases, so I use the first one.

--Steve
Copy linkTweet thisAlerts:
@NogDogApr 02.2006 — I suppose it depends on why and how you're using those URL vars. You could copy them into hidden field values in the form, or save them as session variables. At least those are the first two things that jump to mind, but I'll need more details before I can give any firm recommendation.
Copy linkTweet thisAlerts:
@NogDogApr 02.2006 — I'd probably just use $_SESSION array variables to track all these things, as opposed to passing them between pages via the URL.
Copy linkTweet thisAlerts:
@gameguy43authorApr 02.2006 — then that's how I shall do it ?

one question though, will these variables still fully work without cookies on on the client side?
Copy linkTweet thisAlerts:
@NogDogApr 02.2006 — If your PHP installation is set up for using cookies to track session IDs, then you'll need to override it via a .htaccess file with the following lines:
<i>
</i>php_value session.use_cookies "0"
php_value session.use_trans_sid "1"

Note. however, that there are some security/usability issues with this, since a user could cut-and-paste or bookmark a URL that contains the session ID.
×

Success!

Help @gameguy43 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...