We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Print INPUT VALUE to file

Biffo
Biffo asked
on
Medium Priority
265 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);
}
Comment
Watch Question

Author

Commented:
Edited text of question

Commented:
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

Commented:
$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!

Author

Commented:
Ok alamo, post the boilerplate code for the above!
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
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

Commented:
Sorry, Martin, but you are wrong - that won't work at all. You better look at it again.

Commented:
Well, then is my Perl-book wrong.
Apologize...

Martin
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.