Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Request number is not showing in simple script


This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1 tinycoder

tinycoder

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 20 November 2012 - 12:04 AM

Hello,

I have a simple perl script which is working fine except it deoesn't show maintenance request number after submit the html form. Here are the file names and codes:

maintenance-request.htm file contains the following lines:

<HTML>
<HEAD><TITLE>Maintenance Request Form</TITLE>
</HEAD>
<BODY bgColor=#ffffff background="/images/scanner_background2.gif">
<H1 align="center"><u><font face="Matisse ITC" size="7" color="#0000FF">PC
Maintenance Request Form</font></u></H1><P></P>
<FORM action=/cgi-bin/maintenance-request.pl method="post">
<P> <font size="4"><b> Enter your <u>Full Name</u> below:</b></font><p>
<INPUT TYPE="TEXT" NAME="full_name" SIZE="60" value="Type Your Full Name Here"></P>
<P> <font size="4"><b> Enter your PC Maintenance <u>Request</u> below:
<p><TEXTAREA NAME="request" ROWS=4 COLS=60>State the nature of your problem here </TEXTAREA></b></font></P>

<INPUT type=submit value="Click here to Submit your Request">
</FORM>
</BODY>
</HTML>

maintenance-request.pl contains the following lines:

#!/usr/local/bin/perl

use CGI qw( :standard );
my $remote_address = $ENV{'REMOTE_ADDR'};
my $full_name=param('full_name');
my $request=param('request');
open(REQUEST, ">>text-files/maintenance-log.txt") || &ErrorMessage;
print REQUEST "$remote_address, $full_name, $request\n";
close(REQUEST);
print "Content-type: text/html\n\n";
print "<P>Your Name is:&nbsp;<b>$full_name</b><br>";
print "Your Remote Address is:&nbsp;<b>$remote_address</b><br>";
print "Your Maintenance Request is:<BLOCKQUOTE><b><I>$request</I></b></BLOCKQUOTE>\n";
sub ErrorMessage {
print "Content-type: text/html\n\n";
print "The server can't open the file.<br>";
print "It either doesn't exist or the permissions are wrong. \n";
exit;
}


check-jobs.cgi file contains the following lines:

#!/usr/local/bin/perl
open (REQUEST, "<text-files/maintenance-log.txt") || &ErrorMessage;
@logrequests = <REQUEST>;
close (REQUEST);
print "Content-type: text/html\n\n";
$n=1;
print "<UL><H2>Maintenance Requests List</H2></UL>";
foreach $message (@logrequests) {
	 print "<LI>Message # $n was: <I>$message</I>\n";
	 $n++;
	 }
sub ErrorMessage {
print "Content-type: text/html\n\n";
print "The server can't find the file.<br>";
print "It either doesn't exist or the permissions are wrong. \n";
exit;
}

I am using this script in my windows PC using vmware workstation.
Thanks

#2 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts

Posted 20 November 2012 - 01:16 AM

I suspect of two things, one is the param name: request, which i think could be clashing as keyword somewhere, i would try to change it to requestNum or something, just to check, in the the other hand, maybe your textarea has an enter at first? so you see nothing when you print it ?