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:
HTTP 500 Internal Server Error with HTML and .pl

 



jdp12383
Novice

Feb 12, 2013, 4:13 PM

Post #1 of 9 (766 views)
HTTP 500 Internal Server Error with HTML and .pl Can't Post

Hi,

I am trying to send data from HTML form to perl script and then get result back to browser. I am using latest Mongoose windows webserver. I have attached three files which I am using.

1. HTML page gets the name of visitor and on submit it calls the perl script

2. The script parses the input field NAME and updates the .bin file to store it.

3. It creates HTML content with greeting and sends it back.

4. But when I clicks Apply button it gives me HTTP 500 Internal Server Error.

Can anybody tell me what is going wrong?

I appreciate your inputs.

Thanks,
Attachments: configure.html (1.01 KB)
  getsetParams.pl (1.44 KB)
  data.bin (38 B)


FishMonger
Veteran / Moderator

Feb 12, 2013, 5:20 PM

Post #2 of 9 (761 views)
Re: [jdp12383] HTTP 500 Internal Server Error with HTML and .pl [In reply to] Can't Post

DON'T manually parse the form submission. Use the CGI module to handle the parsing.
http://search.cpan.org/~markstos/CGI.pm-3.63/lib/CGI.pm

You need to send/output the content-type header PRIOR to any other output.

Use the File::CounterFile module to maintain the counter.
http://search.cpan.org/~gaas/File-CounterFile-1.04/CounterFile.pm


jdp12383
Novice

Feb 12, 2013, 5:40 PM

Post #3 of 9 (759 views)
Re: [FishMonger] HTTP 500 Internal Server Error with HTML and .pl [In reply to] Can't Post

Hi FishMonger, Thanks for your comments, Actually this is just for POC. I am new to perl so was not aware of these alternatives.

I verified that the .pl file is executing properly from command prompt. I did following changes and now it is not giving me HTTP 500 error but it is neither receiving any HTML response from script nor updating the data.bin file. It just displays url in the address bar http://localhost:8888/HelloWorld/getsetParams.pl

1. I put the below line on top of the .pl script.

print "Content-type: text/html\n\n";

2. I initialized the name field of input field in html file.

Can you help me finding what went wrong?



Thanks,


FishMonger
Veteran / Moderator

Feb 12, 2013, 6:06 PM

Post #4 of 9 (751 views)
Re: [jdp12383] HTTP 500 Internal Server Error with HTML and .pl [In reply to] Can't Post

Did you check the web server error log?

Try this version, which for now doesn't include the visitor count.


Code
#!/usr/bin/perl 

use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);

my $cgi = CGI->new;
my %form = $cgi->Vars;

print $cgi->header, $cgi->start_html('Hello World');
print $cgi->p("Welcome $form{name}!");
print $cgi->end_html;



jdp12383
Novice

Feb 13, 2013, 11:10 AM

Post #5 of 9 (741 views)
Re: [FishMonger] HTTP 500 Internal Server Error with HTML and .pl [In reply to] Can't Post

Thanks FishMonger for your support in resolving my problem. I appreciate.

I changed code as you suggested but now it is giving me below error but the file is there in the same folder where getsetParams.pl is.

Software error:C:\HelloWorld\getsetParams.pl: Can't open input file data.bin: No such file or directory

For help, please send mail to this site's webmaster, giving this error message and the time and date of the error.

I have attached the files again. Can you please take a look and help.

Thanks,


(This post was edited by jdp12383 on Feb 13, 2013, 11:41 AM)
Attachments: getsetParams.pl (0.83 KB)
  data.bin (40 B)
  configure.html (1.01 KB)


jdp12383
Novice

Feb 13, 2013, 11:40 AM

Post #6 of 9 (739 views)
Re: [jdp12383] HTTP 500 Internal Server Error with HTML and .pl [In reply to] Can't Post

I gave it to the absolute path "C:/HelloWorld/data.bin" and it worked.

It was working fine till tomorrow What you think the reason it is not working now?

Where it looks when I only give the data.bin filename only?

Thanks,


FishMonger
Veteran / Moderator

Feb 13, 2013, 11:51 AM

Post #7 of 9 (736 views)
Re: [jdp12383] HTTP 500 Internal Server Error with HTML and .pl [In reply to] Can't Post

I have never used the Mongoose web server, but my first thought is that it was looking for the file in the web server's "document root" which is probably not where the file is located.


jdp12383
Novice

Feb 13, 2013, 12:02 PM

Post #8 of 9 (734 views)
Re: [FishMonger] HTTP 500 Internal Server Error with HTML and .pl [In reply to] Can't Post

I tried putting this file there but still it is givig error.

Is there any way I can find where it is looking for file?

STRANGE: It was working fine tomorrow.

Thanks,


FishMonger
Veteran / Moderator

Feb 13, 2013, 12:09 PM

Post #9 of 9 (733 views)
Re: [jdp12383] HTTP 500 Internal Server Error with HTML and .pl [In reply to] Can't Post


Quote
STRANGE: It was working fine tomorrow.


That's because of the time warp. :)

 
 


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

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