Re: Using anchor links within pages defined by GETS



..oO(Mechphisto)

On Feb 23, 1:06 pm, Michael Fesser <neti...@xxxxxx> wrote:
.oO(Mechphisto)

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.)

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
.



Relevant Pages

  • Re: Choosing whitch button will act as submit button
    ... Use the script exactly as supplied for the browser. ... server-code cannot decide whitch button should be the submit button. ... one server side form tag, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: different behavior - localserver vs prod server
    ... But I don't understand what you mean when you say to type the src urls ... into the browser to see if they are correct. ... > Smart Navigation and Client Range checking are implemented by client script, ... and how it behaves on the server. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Is script type="text/perl" OK?
    ... :} I've asked this on a html forum but I'll ask it here also. ... Well, as long as your browser is able to execute the script, sure. ... Since the server is doing the running of the ...
    (comp.lang.perl.misc)
  • Re: system call
    ... I am using a cgi to call a pl script and then pass xml back to ... the web browser. ... as $pid will contain only decimal digits. ...
    (comp.lang.perl.misc)
  • Re: connection drops while script running
    ... The browser send a header to the server, ... kill the connection without notice". ... be carefull with session expiring during script execution. ...
    (comp.lang.php)