Aces High Bulletin Board

General Forums => The O' Club => Topic started by: Wotan on December 17, 2004, 02:45:42 AM

Title: Webpage design hellp; CGI EMail
Post by: Wotan on December 17, 2004, 02:45:42 AM
What I have is an HTML form (squad recruiting application) and I want the applicant to just fill it out click on submit and have the form be emailed off to the Recruiting officer.

Here's a link to the form:

http://4jg53.netprism.net/form.html

As I understand it I create an 'email' template and save it as ASCII text.

But damned if I can get it to work correctly.

I was using this page as a reference:

http://web.mit.edu/wwwdev/cgiemail/user.html

Any help would be appreciated...
Title: Webpage design hellp; CGI EMail
Post by: Saintaw on December 17, 2004, 02:55:03 AM
Don't have much time right now, but here it goes:

The last CGI I used for sending an email is here, bmake sure your file is executable!


#!/usr/bin/perl -wT
use CGI qw(:standard);
#use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;

print header;
print start_html("");

my %form;
my $send_bcc;
my $send_subject;
my $send_msg;
my $send_from;
my $send_raid;
$send_from="myemailaddress\@mydomain.com";
foreach my $p (param()) {
    $form{$p} = param($p);
    #print "$p = $form{$p}
\n";
    if ($p eq "send_bcc") {
    $send_bcc=$form{$p};
  }
    if ($p eq "subject") {
    $send_subject=$form{$p};
  }  
    if ($p eq "msg") {
    $send_msg=$form{$p};
  }  
    if ($p eq "raid") {
    $send_raid=$form{$p};
  }
}

sendmail($send_from,$send_bcc,$send_subject,$send_msg);

print end_html;

sub sendmail {
    my ($from, $bcc, $subject, $message) = @_;
    $ENV{PATH} = "/usr/lib";
    open (MAIL, "|/usr/lib/sendmail -oi -t") or
        &dienice("Can't fork for sendmail: $!\n");
    print MAIL "From: $from\n";
    print MAIL "Bcc: $bcc\n";
    print MAIL "Subject: $subject\n\n";
    print MAIL "$message\n";
    close(MAIL);
}
sub dienice {
    my($errmsg) = @_;
    print "

Error

\n";
    print "

$errmsg

\n";
    print end_html;
    exit;
}



In here the variables "$send_bcc,  $send_subject, $send_msgetc..." are defined by the form fields, up to you to change them.

If you can't get it to work, send your script to saw_at_onpoi_dot_net. I'll get around it this week end.

OT:
For the options:

 Yes, I have a mic and use Teamspeak.
No, I dont have a mic.
I have a mic but I cannot get Teamspeak to work.


Use an input type "radio" instead of an input type "checkbox" if you want your users to select only one option.
Title: Webpage design hellp; CGI EMail
Post by: Wotan on December 17, 2004, 03:00:19 AM
Thanks Saw...

I will give it a few more tries...

Just keep keep your email open :)
Title: Webpage design hellp; CGI EMail
Post by: montag on December 17, 2004, 03:06:48 AM
If I remember right, cant have name of a variable with a space.

NAME=someuniqname nospace

You seem to have alot of those.  everything else looksok. I believe its all passed to the cgi as one long string.
Title: Webpage design hellp; CGI EMail
Post by: Saintaw on December 17, 2004, 04:17:26 AM
Wotan, I have no access to my private email when in the office, If you are waiting for an answer it won't be before tomorrow.

Montag is right: No space in field names, EVAR! use "_" instead.
Title: Webpage design hellp; CGI EMail
Post by: Wotan on December 17, 2004, 04:23:33 AM
Quote
Originally posted by Saintaw
Wotan, I have no access to my private email when in the office, If you are waiting for an answer it won't be before tomorrow.

Montag is right: No space in field names, EVAR! use "_" instead.


No, I haven't sent you anything. I will try to get it figured out later today after I get home from work and if I need help I will email you this weekend.

Thanks for the help!!!
Title: Webpage design hellp; CGI EMail
Post by: jetb123 on December 17, 2004, 01:14:27 PM
If that doesnt work I think you got to use something called ASP. It does somthing to the server.
Title: Webpage design hellp; CGI EMail
Post by: Saintaw on December 17, 2004, 03:35:33 PM
Quote
Originally posted by jetb123
If that doesnt work I think you got to use something called ASP. It does somthing to the server.

:D
Title: Webpage design hellp; CGI EMail
Post by: Eagler on December 17, 2004, 03:42:09 PM
matt's works well

http://www.scriptarchive.com/formmail.html
Title: Webpage design hellp; CGI EMail
Post by: Wotan on December 18, 2004, 05:30:40 AM
Thanks guys I got what I want up...
Title: Webpage design hellp; CGI EMail
Post by: Saintaw on December 19, 2004, 01:51:40 AM
:cool: