http://www.mydomain.com/page.php?pid=sitemap
Now, what if I want to use anchor links? What can I do to make this
work (if possible)?
The traditional: http://www.mydomain.com/page.php#bookmark of course
fails. And I can't add it to the end:
http://www.mydomain.com/page.php?pid=sitemap#bookmark
Any ideas?
Thanks,
Liam
I'm not completely sure of what you want to do...
If you want to replace GET parameters with anchor links, well, you
cannot: the browser does not even send them to the server, so they're
unreachable by PHP. Such links are typically used by client-side
applications like Flash movies or JavaScripts code.
If you want to use *both* simultaneously (for different usage), what
prevents you from doing it? Is it a condition imposed by your customer?
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
My problem in this convolution is HOW to use both.
The GET (in this example, the value of 'pid'), determines the page
content. 'sitemap' actually triggers PHP script in page.php to grab
and include the content of sitemap.php. So the content in the browser
is derived from sitemap(.php).
Now, an anchor link within sitemap.php, so that one can click a link
and have the browser zip down to that anchor...how do I get that to
work in conjunction with a GET which determines the page content.
Like I said, if I try something like:
http://www.mydomain.com/page.php?pid=sitemap#bookmark
The PHP assumes "sitemap#bookmark" is the value of pid, and there's no
file sitemap#bookmark.php, so it fails.
Ultimately the problem may be just pishpoor design in the first place,
using GETs to grab content to get inserted into one page.php to serve
as a universal page template. There may be to way around this problem
without a redesign. :(
Thanks,
Liam
>My problem in this convolution is HOW to use both.
>The GET (in this example, the value of 'pid'), determines the page
>content. 'sitemap' actually triggers PHP script in page.php to grab
>and include the content of sitemap.php. So the content in the browser
>is derived from sitemap(.php).
>
>Now, an anchor link within sitemap.php, so that one can click a link
>and have the browser zip down to that anchor...how do I get that to
>work in conjunction with a GET which determines the page content.
>Like I said, if I try something like:
>http://www.mydomain.com/page.php?pid=sitemap#bookmark
This is how it's supposed to be.
>The PHP assumes "sitemap#bookmark" is the value of pid, and there's no
>file sitemap#bookmark.php, so it fails.
Then you have an error in your code. Did you encode the '#' maybe?
Micha
See, here's the deal, this is what page.php does:
$pid = $_GET['pid']; // get page ID from URL
$filename = 'data/'.$pid.'.php'; // create the filename data will
pull from
$txt_main = file_get_contents($filename);
(Actually, there's some extra code in between which checks to make
sure the submitted value for pid is valid and not a NULL or SQL
injection or something.)
When page.php gets the value of pid, it gets the contents of the
related page, then prints out the content in the appropriate place in
page.php.
So page.php remains the actual page, but the content is always new
based on pid. So, how can you put the href in the link so the URL has
the # and the browser/server understand that once the data is all
loaded...go down to that anchor?
I also tried:
http://www.mydomain.com/page.php#bookmark?pid=sitemap
as that seemed logical based on how the page works...but still no
good.
Thanks for replying.
Liam
No problem so far, but where's the request coming from or how does the
link in the HTML actually look like? What URL is sent to the server?
There's an error somewhere, because your script should never see the
#bookmark part - it's completely handled by the browser and never sent
to the server.
>When page.php gets the value of pid, it gets the contents of the
>related page, then prints out the content in the appropriate place in
>page.php.
>So page.php remains the actual page, but the content is always new
>based on pid. So, how can you put the href in the link so the URL has
>the # and the browser/server understand that once the data is all
>loaded...go down to that anchor?
As already said:
http://www.example.com/page.php?pid=sitemap#bookmark
is the correct way. Anything before the # is the URL and sent to the
server as a request, the part after it is called fragment identifier and
used only in the browser - the server won't see it. But obviously this
doesn't seem to work as it should in your case, so my guess was that
maybe your # is encoded in some way by mistake, e.g.
http://www.example.com/page.php?pid=sitemap%23bookmark
This would yield the result that you see with "sitemap#bookmark" being
passed as the pid parameter.
>I also tried:
>http://www.mydomain.com/page.php#bookmark?pid=sitemap
>as that seemed logical based on how the page works...but still no
>good.
This is wrong, because now 'bookmark?pid=sitemap' would be seen as the
fragement identifier and your script won't receive any parameter at all.
Micha
Thanks for the replies and helping this clueless one. :)
Liam
>[..snip..]
>OMG! I'm an idiot. You totally clue-by-foured me.
>The link to the anchor was:
><a href="?pid=sitemap#sep">
>I changed it to:
><a href="page.php?pid=sitemap#sep">
>and it worked. That's all it was.
Hmm ... I don't think that this was the reason, because if this link is
used somewhere on page.php, then both URLs point to exactly the same
document and should work well without any difference.
It must have been something else. But anyway, if it works now, OK.
>Thanks for the replies and helping this clueless one. :)
You're welcome.
Micha
Might is have been because I have in the HTML's HEAD:
<base href="http://www.mydomain.org" />
?
> [..snip..]
Indeed, this would make a difference how the relative URLs are resolved:
?pid=... => http://www.mydomain.org/?pid=...
page.php?pid=... => http://www.mydomain.org/page.php?pid=...
Micha
This would be a problem if the current page were not already
"page.php".
> > >I changed it to:
> > ><a href="page.php?pid=sitemap#sep">
> > >and it worked. That's all it was.
Do you have an index.php? If the current page were index.php (or
another script/document in the same directory), that's one possible
reason why "page.php?pid=sitemap#sep" worked, but not the former.
> > Hmm ... I don't think that this was the reason, because if this link is
> > used somewhere on page.php, then both URLs point to exactly the same
> > document and should work well without any difference.
>
> Might is have been because I have in the HTML's HEAD:
> <base href="http://www.mydomain.org" />
> ?
Possibly.
> > [..snip..]
In any case, at least you got it working.
--
Curtis
$email = str_replace('sig.invalid', 'gmail.com', $from);