PDA

View Full Version : Please Need help grabbing 2 variables - cgi


topache
04-26-2005, 04:24 AM
Hi,

Please I need your help.

I'm trying to make something out of a cgi form mail script.

I have everything working so far except for 1 little detail that is giving me a headache.

What I'm trying to accomplish is to have a form someone can fill out where they type in the begining of an email address in 1 field (ex johndoe) then from a drop down list select the second part (ex @you.com or @me.com) then fill out the other 2 fields and be able to send that to the approciate place. (either johndoe@you.com or johndoe@me.com).

If you look at my script below you can see where I'm trying grab the begining and end of the email using 2 fields. It runs without any errors, but I don't get the email sent to me.

Can anyone help PLEASE! and THANKYOU!!

Part of the html form where I have the 2 fields, 1 to type in johndoe and the selection list to select either @you.com or @me.com

<TD align="left" width="20%"><B>Email Address:</B></TD>
<TD><input type="text" name="first">
@<select name="second" size="1">
<option value="@me.com" selected>me.com</option>
<option value="@you.com">you.com</option>
</select>

********Part of the cgi:*********

use strict;

use CGI;

my $cgiobject = new CGI;

my $MailProgram = '/usr/lib/sendmail';
my $first =$cgiobject->param("first");
my $second =$cgiobject->param("second");

print "Content-type: text/html\n\n";

open (MAIL,"|$MailProgram -t") || &errormess;
print MAIL "To: $first($second)\n"; ***************
print MAIL "From: $email_add\n";
print MAIL "Reply-to: $email_add\n";
print MAIL "Subject: Email From Your Website\n";
print MAIL "Name $fname\n";
print MAIL "email $email_add\n";
print MAIL "Msg $email_msg\n";
close(MAIL);

Where you see my ***** is where I'm trying to open my sendmail and have it put in an email to: johndoe@you.com ($first which it typed and @you.com which is selected)

Thanks for any help

systray
04-26-2005, 09:23 AM
try print MAIL "To: $first$second\n";
instead of
print MAIL "To: $first($second)\n";

topache
04-26-2005, 12:16 PM
Hi,
Thanks for your quick response.
Actually I have already tried that. I've tried several combinations like: , ; () [] ect.. but the same thing happens. Everything appears to run fine but the email doesn't get sent.

mlseim
04-26-2005, 01:00 PM
Here's something else to try ...
... some servers require this (I don't know why).

Add a double "newline" after the Subject.

print MAIL "Subject: Email From Your Website\n";
print MAIL "\n\n";

-----------------------

I also forgot to ask if it works when you "hardcode"
in the sender/recipients.