?
Solved

Print INPUT VALUE to file

Posted on 1998-06-25
8
Medium Priority
?
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Author Comment

by:Biffo
ID: 1208188
Ok alamo, post the boilerplate code for the above!
0
 
LVL 2

Accepted Solution

by:
tpryor earned 100 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
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…
Six Sigma Control Plans

777 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