Contact US

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!

*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

process form WITHOUT output?

process form WITHOUT output?

process form WITHOUT output?

...this qualifies as a question from an
idiot, perhaps. i want to hack a formmail-type
script to process a form and print(MAIL
*WITHOUT* subsequently writing to a "response"
html page or "redirecting." my hacks all fail
when they don't include a print to file0
or redirect. obvoiusly, i'm missing something
elementary in the way perl interacts with
forms. enlighten me, somebody.

RE: process form WITHOUT output?

Please show the part of your script that's failing.

"If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."

RE: process form WITHOUT output?

thanks... here's the whole thing...comment shows where it fails. when i write to an output file (http) instead of exiting, it works,


#!/usr/local/bin/perl -w

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
#read input
@pairs = split(/&/, $buffer);
#split input up
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
#input separated

$mailprog = 'bin/sendmail';
#specify mail address

$recipient = 'adam@hermes-grp.com';
#specify email address

$subject = 'Form Submission';
#specify subject
$redirect = 'http://www.mallophaga.com/frames.htm';
#specify URL to go to once mail has been sent

@days = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
    @months = ('January','February','March','April','May','June','July',
#create array with months and days for later use in mail

    ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
    if ($hour < 10)
        { $hour = "0$hour"; }
    if ($min < 10)
        { $min = "0$min"; }
    if ($sec < 10)
        { $sec = "0$sec"; }
    $date = "$days[$wday], $months[$mon] $mday, 19$year at $hour\:$min\:$sec";
#specify time and date

open (MAIL, "|$mailprog -t") or &dienice("Can't access $mailprog!\n");
#start email
print MAIL "To: $recipient\n";
#print recipient
print MAIL "Reply-to: $FORM{'email'} ($FORM{'name'})\n";
#print reply to information
print MAIL "Subject: $subject\n\n";
#print subject
print MAIL "\n";
#print blank line
print MAIL " The following form was sent by: $FORM{'name'}\n";
#print sent from
print MAIL " on $date\n\n";
#print date
print MAIL "\n\n";
#print 2 blank lines

foreach $key (keys(%FORM)) {
print MAIL "$key : $FORM{$key}\n\n";

#fails below, sends mail but yields server config error
#close(send) email

#error handle code:
sub dienice {
($errmsg) = @_;
print "<center><h2>There was an ERROR sending this form</h2></center>\n";
print "$errmsg<p>\n";
print "</body></html>\n";

RE: process form WITHOUT output?

Oh, i get it, you just want it to perform the function and not return anything to the browser.  I have been taught to always return something, or in the least, to redirect to the original page's location.
 i don't know if doing so is absolutely necessary, but i don't know of any ways around it.  i'll look and ask around here and report if i do find something.
 oh wait, you could just have javascript on the original page to execute the cgi script as it's function, but not reload the whole page (maybe).  i don't know enough javascript off-hand.  like i said, i'll ask, see if anyone knows (as i'd like to know myself).

"If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."

RE: process form WITHOUT output?

...can i do this by opening STDOUT to dev/null?

if so, how?

any help will be appreciated...

RE: process form WITHOUT output?

No, it's that the browser or webserver (i don't know which, probly the webserver, though) is expecting a return, it doesn't have anything to do with the perl.
 Also, noone i knew had an answer better than what i wrote.  Maybe someone else here does, but they have yet to post...

"If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."

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