LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   why this simple cgi script doesnot work ? . (https://www.linuxquestions.org/questions/programming-9/why-this-simple-cgi-script-doesnot-work-542951/)

adam_blackice 04-03-2007 08:21 AM

why this simple cgi script doesnot work ? .
 
hello all ...,

i started in cgi scripts cuz i need it for an project issue by the way i start to run simple scripts with perl also but i found an error with this simple script
PHP Code:

#!/usr/bin/perl -w
use strict;

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

print 
"<html><head><title>Our First HTML Perl form</title></head>";
print 
"<body>";
print
"form method='post' action='action.pl'>";

print
"Name: <input type='text' name='name' size='25'><br>";

print
"Email: <input type='text' name='email' size='25'><br>";

print
"<input type='submit' value='Submit'>";

print
"</form>";
print
"</body></html>"

and when i run it by the browser ......

the fields for the user input's appear but also this appears in browser beside it .....

form method='post' action='action.pl'>Name:
Email:

and when i click submit there is nothing happen !!!!!!

However the action1.pl is created also

PHP Code:

#!/usr/bin/perl -w
use strict;
use 
cgi;

my $cgi=new CGI;

print 
$cgi->header();
print 
$cgi->start_html("Action page");
print 
$cgi->param('name'), "<br>";
print 
$cgi->param('email');
print 
$cgi->end_html(); 

what is wrong ...plz help me :)

Guttorm 04-03-2007 08:56 AM

The line:
Code:

print"form method='post' action='action.pl'>";
is missing the first "<" character, no?

adam_blackice 04-03-2007 02:32 PM

OOoooOOops i forget that and thanx for you help :) it works

////// 04-03-2007 10:45 PM

Hi, I use this kind of start in my cgi's.
It produces cgi-error.log if there is something wrong with it.
Code:

#!/usr/bin/perl
$| = 1;
use CGI;
use CGI::Carp;
BEGIN {
      use CGI::Carp qw(carpout);
      open(LOG, ">>/var/log/cgi-error.log")
            or die "Unable to append to cgi-error.log: $1\n";
      carpout(*LOG);
}


theNbomr 04-04-2007 10:50 AM

In addition to what ////// said, I also like
Code:

use CGI::Carp qw(fatalsToBrowser);
This is convenient during the early testing & debugging period.

--- rod.


All times are GMT -5. The time now is 04:22 PM.