Solved

Print INPUT VALUE to file

Posted on 1998-06-25
8
189 Views
Last Modified: 2010-03-05
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:
------------------------------------------------------------
#perl.exe

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

{
 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;
        $ProcessObj->Wait(0);
}
0
Comment
Question by:Biffo
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 2

Author Comment

by:Biffo
ID: 1208185
Edited text of question
0
 
LVL 4

Expert Comment

by:martinag
ID: 1208186
To get the value of email, use $ENV{'HTTP_EMAIL'}.
So this is your only change:
print MAIL "Submitted Address: $email  \n";
to
print MAIL "Submitted Address: $ENV{'HTTP_EMAIL'}  \n";

And the redirect...
Print STDOUT "Location: http://your.site.com/thanks.htm\n\n";

Martin
0
 
LVL 6

Expert Comment

by:alamo
ID: 1208187
$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!
0
 
LVL 2

Author Comment

by:Biffo
ID: 1208188
Ok alamo, post the boilerplate code for the above!
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 2

Accepted Solution

by:
tpryor earned 50 total points
ID: 1208189
http://cgi-lib.stanford.edu/cgi-lib/

go there for the boilerplate, it is called cgi-lib.pl
example code...

#!/usr/local/bin/perl

# $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 cgi-lib.pl library

require "cgi-lib.pl";

MAIN:
{

  # Read in all the variables set by the form
  &ReadParse(*input);

  # Print the header
  print &PrintHeader;
  print &HtmlTop ("cgi-lib.pl 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>

ENDOFTEXT


  # 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;
}

GL
t
0
 
LVL 4

Expert Comment

by:martinag
ID: 1208190
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.

Martin
0
 
LVL 6

Expert Comment

by:alamo
ID: 1208191
Sorry, Martin, but you are wrong - that won't work at all. You better look at it again.
0
 
LVL 4

Expert Comment

by:martinag
ID: 1208192
Well, then is my Perl-book wrong.
Apologize...

Martin
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now