×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Forms: Works on UNIX doesn't work on Microsoft

Forms: Works on UNIX doesn't work on Microsoft

Forms: Works on UNIX doesn't work on Microsoft

(OP)
ok, now that I've got Perl working on my Microsoft Server I'm now able to run my Form program.  Only problem is a slight bug.  

What I would like to do is submit a form that has a 'lastname', 'password', and 'request' to a perl program which takes the users input and store it in a file that has a file name equal to the 'lastname' variable.

The output of the program as currently written is "success11" and it is stored in a file with the name of '1'.

clearly the cgi script is able to obtain the data from the form.

The script works in unix....can anyone help out here?

thanks very much....

Jerry


=============================

Here is the file "example2.pl" on the NT server:



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

$file="$FORM{'lastname'}"¦¦print "Failed to assign $file,$!<BR>\n";
$password="$FORM{'password'}"¦¦print "Unable to assign
$password,$!<BR>/n";
$request="$FORM{'request'}"¦¦print "Unable to assign $password,$!<BR>/n";
open(OUT,">$file")¦¦print "Failed to open $file,$!<BR>\n";

print "<HTML>\n<BODY>\n";
print "</BODY>\n";
print"<p>Your data has been successfully sent to the web
server\n</p>";
print OUT "success";
print OUT $lastname;
print OUT $password;
print OUT $request;
close(OUT)¦¦print "Failed to close $file, $!<BR?\n";
exit;


sub get_form_data
{
  #Get the input
  read(STDIN, $buffer, $ENV{ 'CONTENT_LENGTH' } );
  #Split the name-value pairs
  @pairs = split(/&/, $buffer);
  foreach $pair (@pairs)
  {
    ($name, $value) = split(/=/, $pair);
    # Un-webify plus signs and %-encoding
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $value =~ s/<v!--(.¦\n)*-->//g;
    $FORM{ $name } = $value;
  }
}


Here is HTML program that references the above CGI file:


<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>

<body>

<form method="POST" action="cgi-bin/example2.pl">
  <p>Lastname: <input type="text" name="lastname" size="20"></p>
  <p>Password: <input type="text" name="password" size="20"></p>
  <p>Request:    <input type="text" name="request" size="20"></p>
  <p> </p>
  <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>

</body>

</html>

RE: Forms: Works on UNIX doesn't work on Microsoft

(OP)
I've done more work on this and still can't get it to work in Microsoft IIS with latest active perl installed (work fine on a unix server).  

I've added some better error descriptions in the code to help the process.

The program should accept data from the user via a web page, write the data to a file, then send a new web page back to the user announcing a success.

The filename that is created should equal the contents of the 'lastname' that is entered on the form.

The program seems unable to receive the data entered into the form, the data then seems to default to a value of one...then a file is created with the name of '1' and the other two values from the form are also entered as '1' into the text file.  Also, web user doesn't get a nice new web page to look at.

I'm user a single work station to run IE to access the web page and enter the data; hence there shouldn't be any network problems.

Still stuck but trying on my own...

Can anyone take a quick look and provide advice?

thanks/ Jerry

====== contents of the file output file named "1"  ======

"success transmission11"

(notice the 11 on the end.  This seems to be the value Perl is using for the form input vice the real text input.  This does work on unix....strange).

======  contents of the perl file called "example4.pl"  ====

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

$file="$FORM{'lastname'}"¦¦print "Failed to assign file name $file,$!<BR>\n";
$password="$FORM{'password'}"¦¦print "Unable to assign password $password,$!<BR>/n";
$request="$FORM{'request'}"¦¦print "Unable to assign request $password,$!<BR>/n";
open(OUT,">c:$file")¦¦print "Failed to open $file,$!<BR>\n";

print "<HTML>\n<BODY>\n";
print "</BODY>\n";
print"<p>Data successfully sent to the web server\n</p>";          
print OUT "success transmission";
print OUT $lastname;
print OUT $password;
print OUT $request;
close(OUT)¦¦print "Failed to close $file, $!<BR>\n";
exit;


sub get_form_data
{
  #Get the input
  read(STDIN, $buffer, $ENV{ 'CONTENT_LENGTH' } );
  #Split the name-value pairs
  @pairs = split(/&/, $buffer);
  foreach $pair (@pairs)
  {
    ($name, $value) = split(/=/, $pair);
    # Un-webify plus signs and %-encoding
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $value =~ s/<v!--(.¦\n)*-->//g;
    $FORM{ $name } = $value;
  }

}

====== contents of HTML file that calls example4.pl ======

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>

<body>

<form method="POST" action="cgi-bin/example2.pl">
  <p>Lastname: <input type="text" name="lastname" size="20"></p>
  <p>Password: <input type="text" name="password" size="20"></p>
  <p>Request:    <input type="text" name="request" size="20"></p>
  <p> </p>
  <p><input type="submit" value="Submit" name="submit"><input type="reset" value="Reset" name="reset"></p>
</form>

</body>

</html>

RE: Forms: Works on UNIX doesn't work on Microsoft

(OP)
Problem Solved!

IIS configuration problem.

RE: Forms: Works on UNIX doesn't work on Microsoft

Could you let us know what the problem was? It sounds like the kind of thing people are going to come up against time and time again.

Mike
michael.j.lacey@ntlworld.com
Cargill's Corporate Web Site
Please -- Don't send me email questions without posting them in Tek-Tips as well. Better yet -- Post the question in Tek-Tips and send me a note saying "Have a look at so-and-so in the thingy forum would you?"

RE: Forms: Works on UNIX doesn't work on Microsoft

(OP)
Not a problem...I think it will be useful for others.  

Right now I'm building another Microsoft web server that will run Perl and ASPs.  I'm writing down the steps plus what I did wrong the 1st time.  I'll post it as a separate thread in the ASP & Perl areas (I had postings in both areas last week).

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close