Print INPUT VALUE to file

I am printing a very simple mail form to a temp file to be mailed with windmail
and need some vision on how to include the forms input value into my little file
"<INPUT TYPE=TEXT NAME="email" SIZE=25  ROWS="1">".  Essentialy,
a user will just type in their email address and then click Submit which calls the little
script below to print the submitted email address to a temp file ($email).
Also, if you could add a little snippet at the end to call a confirmation
page would be nice to.

Sample script:

$dir = "c:/windows/temp";
$mailprog = 'windmail.exe';
$To = "listserver\";

 open(MAIL,">$dir\\tempfile") || die("Cannot open $dir\\tempfile -- Check Directory Permissions : $!");

    print MAIL "From: $To\n";
    print MAIL "To: $To\n";
    print MAIL "Subject: E-mail Submission\n\n";
    print MAIL "------------------------------------------\n";
    print MAIL "Submitted Address: $email  \n";
    print MAIL "------------------------------------------\n\n";
    close (MAIL);
        use Win32::Process;
        use Win32;
        Win32::Process::Create($ProcessObj, $mailprog, "windmail -t -n $dir/tempfile ", 0, DETACHED_PROCESS, ".")|| die;
Who is Participating?
tpryorConnect With a Mentor Commented:

go there for the boilerplate, it is called
example code...


# $Header: /cys/people/brenner/http/docs/web/RCS/simple-form.cgi,v 1.4 1996/03/29 22:07:56 brenner Exp $
# Copyright (C) 1994 Steven E. Brenner
# This is a small demonstration script to demonstrate the use of
# the library

require "";


  # Read in all the variables set by the form

  # Print the header
  print &PrintHeader;
  print &HtmlTop (" demo form output");

  # Do some processing, and print some output
  ($text = $input{'text'}) =~ s/\n/\n<BR>/g;
                                   # add <BR>'s after carriage returns
                                   # to multline input, since HTML does not
                                   # preserve line breaks

  print <<ENDOFTEXT;

You, $input{'name'}, whose favorite color is $input{'color'} are on a
quest which is $input{'quest'}, and are looking for the weight of an
$input{'swallow'} swallow.  And this is what you have to say for
yourself:<P> $text<P>


  # If you want, just print out a list of all of the variables.
  print "<HR>And here is a list of the variables you entered...<P>";
  print &PrintVariables(*input);

  # Close the document cleanly.
  print &HtmlBot;

BiffoAuthor Commented:
Edited text of question
To get the value of email, use $ENV{'HTTP_EMAIL'}.
So this is your only change:
print MAIL "Submitted Address: $email  \n";
print MAIL "Submitted Address: $ENV{'HTTP_EMAIL'}  \n";

And the redirect...
Print STDOUT "Location:\n\n";

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

$ENV{'HTTP_EMAIL' is not the value the user entered into the form.

Since this is a result of a forms submission, you need to do the standard translation and parsing of QUERY_STRING (if it's a GET, STDIN if it's a POST) into a hash, and then use the value of 'email' from that hash.

This is boilerplate stuff available in a lot of places (once you know what to look for), but if you want the exact code, say so and I'll post it. good luck!
BiffoAuthor Commented:
Ok alamo, post the boilerplate code for the above!
The code I submitted works. It's easy to use if you only use one, maybe two, variables.
If the form consists of more variables, I think that one should use tpryor's splitting code.

Sorry, Martin, but you are wrong - that won't work at all. You better look at it again.
Well, then is my Perl-book wrong.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.