CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Address showing redir.pl not true url

 



Dingo
Novice

Nov 8, 2010, 10:05 AM

Post #1 of 5 (482 views)
Address showing redir.pl not true url Can't Post

I'm having what I hope is a simple problem with an HTML dropdown that calls a perl script.

Here is a link to my test page.

http://www.phoenixarizonanetwork.com/test.htm

When I make a choice it goes to the page fine. However in the address bar of the browser it shows the perl link, not the true url.

For instance if I click dogs I get this URL in the address bar.

http://www.phoenixarizonanetwork.com/cgi/redir.pl

Not

http://www.phoenixarizonanetwork.com/dogs.htm

How can I make it show the true address, not the perl link?

I'm not sure if my code matters but here is my perl script.

#!/usr/bin/perl

sub xcgi_InitForm
{
my($h) = '[a-fA-F0-9]';
my($buff, @params, $param);
my($param_name, $param_value);
local(*xcgi_form) = @_ if @_;

read(STDIN, $buff, $ENV{'CONTENT_LENGTH'});

@params = split(/&/, $buff);

foreach $param (@params)
{
($param_name, $param_value) = split(/=/, $param);

$param_value =~ tr/+/ /;
$param_value =~ s/%($h$h)/pack("C",hex($1))/eg;

$xcgi_form{$param_name} = $param_value;
}
}

{
my(@form);

xcgi_InitForm(*form);

$url = $form{'url'};
print "Location: $url\n\n";
}


Zhris
User

Nov 8, 2010, 4:05 PM

Post #2 of 5 (468 views)
Re: [Dingo] Address showing redir.pl not true url [In reply to] Can't Post

Hi,

Looks like you are incorrectly using relative web addresses in your HTML form. Try using:

- Proper relative address based on your directory structure e.g.

Code
<option value="../cats.htm">Cats</option>


- Full URL e.g.

Code
<option value="http://www.phoenixarizonanetwork.com/cats.htm">Cats</option>


To add, unless this is just a section of a larger program, I would choose to perform this task using javascript.

Code
<select onChange="window.location=this.value">      
<option value="http://www.amazon.com">Amazon</option>
<option value="http://www.google.com">Google</option>
</select>


Chris


(This post was edited by Zhris on Nov 8, 2010, 4:22 PM)


Dingo
Novice

Nov 8, 2010, 7:29 PM

Post #3 of 5 (449 views)
Re: [Zhris] Address showing redir.pl not true url [In reply to] Can't Post

Zhris you are brilliant!

I changed the code to...

<option value="../cats.htm">Cats</option>

...and the true url shows up in the address bar!

How did you know to do that? I validated my code on the W3C and it didn't even give me a warning for that error!

http://validator.w3.org/

Thank you so much!


Zhris
User

Nov 8, 2010, 8:35 PM

Post #4 of 5 (445 views)
Re: [Dingo] Address showing redir.pl not true url [In reply to] Can't Post

No problem,

An issue like that won't be recognized by the W3C validator. A form field must be capable of allowing nearly any form of string as its value. The W3C validator couldn't possibly know what that value means or how you intend to use it, it doesn't neccessarily have to be a relative path to a webpage.

In general, you use "dir/page.html" for the lower level directory, "page.html" for the working directory, "../page.html" for the upper level directory. From briefly checking your form source, I knew that "/page.html" isn't a suitable relative path, nor would it work in your case, because your html pages lie on the upper level directory in relation to your perl script. It was the only obvious mistake.

Chris


Dingo
Novice

Nov 9, 2010, 5:21 AM

Post #5 of 5 (435 views)
Re: [Zhris] Address showing redir.pl not true url [In reply to] Can't Post

Thanks Chris!

"In general, you use "dir/page.html" for the lower level directory, "page.html" for the working directory, "../page.html" for the upper level directory."

I'm going to put that in a txt file for reference.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives