Hi,

Please see the below one :

#!c:/perl/bin/perl
use CGI qw(:all);

print "Content-type:text/html\n\n";
print <<EndOfHTML;
<html><head><title>Print Environment</title></head>
<body>
<FORM action="sample.cgi" method="POST">
First Name: <input type="text" name="first_name">  <br>

Last Name: <input type="text" name="last_name">

<input type="submit" value="Submit">
</FORM></body>
EndOfHTML

From this, i don't know to proceed. There are two text box with First Name and the Last Name. When submitting the form by clicking "submit button", the First Name and the Last Name should display on the same page, that is at the bottom of the two text boxes. Please help me out. Thanks in advance

#!/usr/bin/perl
use strict;
use warnings;

use CGI qw(:all);

#Create a new CGI object
my $cgi = new CGI;
my $this_url = $cgi->url(); #Save this script's url
my $first = $cgi->param('first_name');
my $last = $cgi->param('last_name');

print "Content-type:text/html\n\n";
print <<EndOfHTML;
<html><head><title>Generating Self-Referential URLs</title></head>
<body>
<FORM action="$this_url" method="POST">
First Name: <input type="text" name="first_name">  <br>

Last Name: <input type="text" name="last_name">

<input type="submit" value="Submit">
</FORM>
<p>The name you entered was '$first $last'</p> 
</body>
EndOfHTML
#Put a comment or linefeed after EndOfHTML
#Otherwise perl might not find it.

hi,

I am facing Internal Server Error. In Apache Error Log is 
[Wed Mar 02 22:05:24 2011] [error] [client 127.0.0.1] (OS 3)The system cannot find the path specified.  : couldn't create child process: 720003: sample2.cgi
[Wed Mar 02 22:05:24 2011] [error] [client 127.0.0.1] (OS 3)The system cannot find the path specified.  : couldn't spawn child process: C:/Program Files/Apache Group/Apache2/cgi-bin/sample2.cgi

The code for sample2.cgi is

#!/usr/bin/perl
use strict;
use warnings;
use CGI qw(:all);
#Create a new CGI object
my $cgi = new CGI;
my $this_url = $cgi->url('C:/Program Files/Apache Group/Apache2/cgi-bin/sample2.cgi'); #Save this script's url
my $first = $cgi->param('first_name');
my $last = $cgi->param('last_name');
print "Content-type:text/html\n\n";
print <<EndOfHTML;
<html><head><title>Generating Self-Referential URLs</title></head>
<body>
<FORM action="$this_url" method="POST">
First Name: <input type="text" name="first_name"> <br>
Last Name: <input type="text" name="last_name">
<input type="submit" value="Submit">
</FORM>
<p>The name you entered was '$first $last'</p>
</body>
EndOfHTML
#Put a comment or linefeed after EndOfHTML
#otherwise perl might not find it

I don't know, what mistake, i am doing? thanks

The following works for me. my $this_url = $cgi->url(); Don't put anything between the parentheses. You put the full path to your script file and Apache doesn't understand that. The $cgi->url() method should retrieve the correct url for the script that you are running, so that when you submit your form it should go to the same script containing that form. You can read about this at OBTAINING THE SCRIPT'S URL

hi,

Again, i am facing the same error. In url(), i did not supplied any parameter as you told. Why my script is not running?

regards,
santhanalakshmi

Hi,

Thanks for your help...i got the output. thanks for your coding

Hi,

Thanks for your help...i got the output. thanks for your coding

You're welcome. Please don't forget to mark this thread 'solved'.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.