I need to be able to figre out what the current page is in order to determin the proper path for an external PHP file. How do I capture the URL? (I can figure out the rest).
I need to be able to figre out what the current page is in order to determin the proper path for an external PHP file. How do I capture the URL? (I can figure out the rest).
--Jas
function GreatMinds(){ return "Think Like Jas"; }
Well, you could use the combination of the $_SERVER variables to figure get this information. An example:
This will display something along the lines of http://yourdomain.com/dir/file.phpCode:echo "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
Hope this helps.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design
Hmm... $_SERVER['REQUEST_URI'] is quicker. That's exactly what was requested, though it would include extra stuff on the end, like get variales (.htm?var=value) and anchors (.htm#pictures).
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
But you could use explode to split the url at the ? or #:
So then $newurl[0] would be the url without the get variables. You can do this with anchors, too, by just replacing the "?" with "#"PHP Code:$url = $_SERVER['REQUEST_URI'];
$newurl = explode("?",$url);
But using Testing's solution is probably easier, anyway.
Thou com'st in such a questionable shape
Hamlet, Act 1, Scene 4
It depends if the get variables are needed. In some cases, those determine how the page functions, like with a site based on a database with articles definied in the url, etc.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
I didn't mean to spark a debat lol. Anyway, thanks! I figured it out and the script works perfect! That right: MY LOGGIN SCRIPT IS FINALLY DONE! Over 1,000 lines-- whew! But you need not think that it runs slowly. Each file is used for different aspects of the script, for instance blocking users. Thanks for all of your help DD. Can't wait until I figure out what my next project will be. . .
--Jas
function GreatMinds(){ return "Think Like Jas"; }
Mike, is that true if it is sent as the url?
For example, clicking this link:
<a href="mypage.htm#pictures">click</a>
I realize it wouldn't be part of the request if it were just on the page, using it as a target to move up or down to a specific section, but I'd think it would be part of it were it included that way. I was under the impression (perhaps just a random guess that I never tested) that you could use the # method to send a value to PHP, much like GET, but just that you would need to code the retrieval yourself (by splitting at '#').
And... if that is the case, then all the better for using the REQUEST_URI string instead.
Anyway, glad it's working. Don't worry about starting a debate. We're just discussing/learning. It's a good thing.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
No, it's entirely client-side.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Yes, that's what I was talking about. You can read for yourself in RFC 2616. You could also test for yourself by changing:
to:<a href="mypage.htm#pictures">click</a>
where mypage.php is:HTML Code:<a href="mypage.php#pictures">click</a>
PHP Code:<?php
header('Content-Type: text/plain');
echo $_SERVER['REQUEST_URI'];
?>No. With other URI schemes, the fragment identifier may actually be significant, but it's not with HTTP.I was under the impression (perhaps just a random guess that I never tested) that you could use the # method to send a value to PHP, much like GET, but just that you would need to code the retrieval yourself (by splitting at '#').
Mike
Bookmarks