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:
HTML/Perl dropdown form problem

 

First page Previous page 1 2 Next page Last page  View All


Dingo
Novice

Aug 27, 2010, 1:19 PM

Post #1 of 36 (5493 views)
HTML/Perl dropdown form problem Can't Post

I'm having a problem calling a simple perl script. When I click the go button in the HTML it sends me to "/cgi/redir.pl" instead of the URL held in the value.

I'm using the Perl script found on this page. http://www.chami.com/tips/internet/042999I.html

Thanks for any help in advance!!!

Here is the script and HTML.


Code
  
#!/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: $urlnn";
}


Here is the HTML

Code
<form method="post" action="/cgi/redir.pl"> 
<select name="url">
<option value="http://www.google.com">Alabama</option>
</select>
<input type="submit" value="Go" />
</form>



Zhris
Enthusiast

Aug 27, 2010, 2:05 PM

Post #2 of 36 (5489 views)
Re: [Dingo] HTML/Perl dropdown form problem [In reply to] Can't Post

Hi,


Code
<form method="post" action="/cgi/redir.pl">


Change the action to point to the actual location of your script.

Chris


(This post was edited by Zhris on Aug 27, 2010, 2:21 PM)


Dingo
Novice

Aug 27, 2010, 2:21 PM

Post #3 of 36 (5481 views)
Re: [Zhris] HTML/Perl dropdown form problem [In reply to] Can't Post

Thanks Chris!

I tried including the complete URL http://www.exampleurl.com/cgi/redir.pl instead of "/cgi/redir.pl" and got the same thing.... Dang.

The dropdown menu (the form) is in the HTML but I tried the $url anyway and it didn't work.

I'm totally stumped. Is there another thing that I could check?


(This post was edited by Dingo on Aug 27, 2010, 2:22 PM)


Dingo
Novice

Aug 27, 2010, 2:24 PM

Post #4 of 36 (5479 views)
Re: [Zhris] HTML/Perl dropdown form problem [In reply to] Can't Post

Chris,

Is there a simple perl script I could put on my server and in my HTML to see if Perl is working in the first place?


Zhris
Enthusiast

Aug 27, 2010, 2:29 PM

Post #5 of 36 (5477 views)
Re: [Dingo] HTML/Perl dropdown form problem [In reply to] Can't Post

Hey,

Try the following, ensure the permissions are set to 755. Run the script directly e.g. http://domain.com/script.pl or http://domain.com/cgi-bin/script.pl etc.

script.pl

Code
#!/usr/bin/perl 
print "Content-type: text/html\n\n";
print "Hello world<br />";


Chris


(This post was edited by Zhris on Aug 27, 2010, 2:30 PM)


Zhris
Enthusiast

Aug 27, 2010, 2:35 PM

Post #6 of 36 (5473 views)
Re: [Dingo] HTML/Perl dropdown form problem [In reply to] Can't Post

When you say its not working, do you mean you are getting a perl error e.g. Error 500, or page not found etc? Excluding the "exampleurl" part, is "http://www.exampleurl.com/cgi/redir.pl" definately the url to your perl script?

Chris


(This post was edited by Zhris on Aug 27, 2010, 2:37 PM)


Dingo
Novice

Aug 27, 2010, 2:36 PM

Post #7 of 36 (5472 views)
Re: [Zhris] HTML/Perl dropdown form problem [In reply to] Can't Post

Hi Chris,

This might sound like a stupid question but what do I put in the HTML?


Dingo
Novice

Aug 27, 2010, 2:37 PM

Post #8 of 36 (5470 views)
Re: [Zhris] HTML/Perl dropdown form problem [In reply to] Can't Post

I was getting

500 Internal Server Error

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, support@supportwebsite.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


(This post was edited by Dingo on Aug 27, 2010, 2:38 PM)


Zhris
Enthusiast

Aug 27, 2010, 2:38 PM

Post #9 of 36 (5469 views)
Re: [Dingo] HTML/Perl dropdown form problem [In reply to] Can't Post

The perl script is creating the HTML for you (the test one I provided). You don't need to create a seperate HTML document, just run the script directly from your browser (script.pl).

Chris


Zhris
Enthusiast

Aug 27, 2010, 2:39 PM

Post #10 of 36 (5467 views)
Re: [Dingo] HTML/Perl dropdown form problem [In reply to] Can't Post

Ok error 500 will mean there is something wrong with your script or configuration. Firstly have you ensured that permissions are set to 755 and that you are uploading the file in ASCII format?

Chris


Dingo
Novice

Aug 27, 2010, 2:41 PM

Post #11 of 36 (5465 views)
Re: [Zhris] HTML/Perl dropdown form problem [In reply to] Can't Post

Yep, same 500 error on your script.

The problem must not be the code. I'm saving my perl in notepad under ANSI format. Could it be that or something liket that?


(This post was edited by Dingo on Aug 27, 2010, 2:42 PM)


Dingo
Novice

Aug 27, 2010, 2:43 PM

Post #12 of 36 (5462 views)
Re: [Zhris] HTML/Perl dropdown form problem [In reply to] Can't Post

Aaaaah....

Ok I'll start saving to ASCII. Where do I set permissions 755?

THANK YOU SO MUCH!!!!


(This post was edited by Dingo on Aug 27, 2010, 2:44 PM)


Zhris
Enthusiast

Aug 27, 2010, 2:48 PM

Post #13 of 36 (5458 views)
Re: [Dingo] HTML/Perl dropdown form problem [In reply to] Can't Post

I'm unfamiliar with ANSI, I can't tell if will it be an issue. If you search "perl error 500" in google, you will find a few different pages providing guidelines in determining the likely cause of this error, and how to fix it. Its one of those problems thats sometimes difficult to help someone with without further information such as host etc.

Chris


(This post was edited by Zhris on Aug 27, 2010, 2:50 PM)


Dingo
Novice

Aug 27, 2010, 2:50 PM

Post #14 of 36 (5455 views)
Re: [Zhris] HTML/Perl dropdown form problem [In reply to] Can't Post

Actually maybe the problem is my uploader. I'm just copying files between windows.

Do I need a special program to send it to the server in ASCII?


Zhris
Enthusiast

Aug 27, 2010, 2:51 PM

Post #15 of 36 (5452 views)
Re: [Dingo] HTML/Perl dropdown form problem [In reply to] Can't Post

Usually files are uploaded via an FTP client, if you are using an FTP client, there will be an option to ensure files are uploaded in this format.

Chris


Zhris
Enthusiast

Aug 27, 2010, 3:03 PM

Post #16 of 36 (5441 views)
Re: [Dingo] HTML/Perl dropdown form problem [In reply to] Can't Post

I'm a little bit confused:


Quote
When I click the go button in the HTML it sends me to "/cgi/redir.pl" instead of the URL held in the value.


Which sounds as if the script originally ran for you, without any errors?

Chris


Dingo
Novice

Aug 27, 2010, 3:07 PM

Post #17 of 36 (5439 views)
Re: [Zhris] HTML/Perl dropdown form problem [In reply to] Can't Post

More specifically I get the 500 Internal Server Error and at the same time I get "/cgi/redir.pl" in the address line of my browser.

Uggh...

My site is hosted on GoDaddy. Dang.



I just tried a program called Classic FTP. It didn't have an option for ASCII but I assume it knew to upload a .pl file in ASCII.


(This post was edited by Dingo on Aug 27, 2010, 3:08 PM)


Zhris
Enthusiast

Aug 27, 2010, 3:09 PM

Post #18 of 36 (5436 views)
Re: [Dingo] HTML/Perl dropdown form problem [In reply to] Can't Post

GoDaddy, does your account use Hosting Config 2.0 ?

http://help.godaddy.com/topic/424/article/1574

Chris


(This post was edited by Zhris on Aug 27, 2010, 3:15 PM)


Dingo
Novice

Aug 27, 2010, 3:29 PM

Post #19 of 36 (5422 views)
Re: [Zhris] HTML/Perl dropdown form problem [In reply to] Can't Post

Thanks for the link Chris!

I just checked and I'm using Hosting Configuration 2.2 which looks like it's new.

Here is the test pl doc from the Godaddy page.

#!/usr/bin/perl

use CGI qw(:standard); print "Content-type: text/html\n\n";
print "Greetings user.\n";

So if I name it script.pl, upload it in ASCII to the bin and then type in... www.myurl.com/bin/script.pl it should work?


Zhris
Enthusiast

Aug 27, 2010, 3:32 PM

Post #20 of 36 (5421 views)
Re: [Dingo] HTML/Perl dropdown form problem [In reply to] Can't Post

Just to add,

I've searched around, and it seems as if many people have difficulties running perl scripts with GoDaddy. It is suggested to check your server error logs, or contact GoDaddy for advise on solving your issue / consult their documentation.

Chris


Zhris
Enthusiast

Aug 27, 2010, 3:35 PM

Post #21 of 36 (5420 views)
Re: [Dingo] HTML/Perl dropdown form problem [In reply to] Can't Post

It would be a good idea to try that script, although I can't see how "use CGI qw(:standard);" will fix this issue, although you never know.


Quote
So if I name it script.pl, upload it in ASCII to the bin and then type in... www.myurl.com/bin/script.pl it should work?


In theory, that should work, I thought you had already tried this, except with "my" test script.

Chris


(This post was edited by Zhris on Aug 27, 2010, 3:37 PM)


Dingo
Novice

Aug 27, 2010, 3:37 PM

Post #22 of 36 (5416 views)
Re: [Zhris] HTML/Perl dropdown form problem [In reply to] Can't Post

Thanks for helping Chris. At least I've got it narrowed down.

I can't believe how hard it is to load and test a simple file! Damn you GODADDY!!!

@!%#@!#$@!$#@!#$


(This post was edited by Dingo on Aug 27, 2010, 3:38 PM)


Dingo
Novice

Aug 27, 2010, 3:39 PM

Post #23 of 36 (5413 views)
Re: [Zhris] HTML/Perl dropdown form problem [In reply to] Can't Post

BTW I tried the Godaddy script and it didn't work.

What the heck, the default Godaddy setting is perl off?!? I gotta contact them.


Zhris
Enthusiast

Aug 27, 2010, 3:41 PM

Post #24 of 36 (5411 views)
Re: [Dingo] HTML/Perl dropdown form problem [In reply to] Can't Post

Have you checked your error logs first, they may give you a clue as to why you recieve error 500? Does the GoDaddy control panel provide a CGI output monitor? Did you manage to try checking if permissions were set to 755? Afterall, GoDaddy support must be able to help you run your first perl script.

Chris


(This post was edited by Zhris on Aug 27, 2010, 3:49 PM)


Dingo
Novice

Aug 27, 2010, 3:51 PM

Post #25 of 36 (5406 views)
Re: [Zhris] HTML/Perl dropdown form problem [In reply to] Can't Post

Ok, I just turned on error logs. (it was off before)

How can I use this to test my problem?

First page Previous page 1 2 Next page Last page  View All
 
 


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

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