Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ Perlscript ➜ Please Need help grabbing 2 variables - cgi

Please Need help grabbing 2 variables - cgi

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Topache   (2 posts)  Bio
Date Tue 26 Apr 2005 12:49 AM (UTC)
Message
Hi,

Please I need your help.

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

I have everything workiing 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. It runs without any errors, but I don't get the email sent to me. If I totally remove the second half and actually type in johndoe@you.com in the 1st field it will send an email their. I just can't get my selection drop down to work.

Can anyone help PLEASE! and THANKYOU!!

Part of the html form:

</HEAD>
<BODY>
<form action="http://anywho.com/cgi-bin/text.cgi" method="post">
<table border="0">
<TR>
<TD COLSPAN="2">Please fill in the details below to send us a message</TD>
</TR>
<TR>
<TD colspan="2">&nbsp;</TD>
</TR>
<TR>
<TD align="left" width="20%"><B>Cell:</B></TD>
<TD><input type="text" name="first">
@<select name="second" size="1">
<option value="\@me.com" selected>Verizon</option>
<option value="@you.com">Cingular</option>
</select>
</TD>
</TR>
<TD align="left" width="20%"><B>Name:</B></TD>
<TD><input type="text" name="fname"></TD>
</TR>
<TR>
<TD align="left" width="20%"><b>Email Address:</b></TD>
<TD><input type="text" name="email_add"></TD>
</TR>
<TR><TD ALIGN=left valign="top" width="20%"><b>Message:</b></TD>
<TD><textarea name="email_msg" rows="20" cols="30"></textarea></TD>
</TR>
<TR>
<TD colspan="2">&nbsp;</TD></TR>
<TR><TD colspan="2"><center><INPUT TYPE="submit" VALUE="Send Message"></center></TD>
</TR>
</TABLE>
</form>

Part of the cgi:

#!/usr/bin/perl

use strict;

use CGI;

my $cgiobject = new CGI;

my $fname=$cgiobject->param("fname");
my $email_add=$cgiobject->param("email_add");
my $email_msg=$cgiobject->param("email_msg");
my $MailProgram = '/usr/lib/sendmail';
my $cell =$cgiobject->param("cell","where");

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

open (MAIL,"|$MailProgram -t") || &errormess;
print MAIL "To: $cell\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);

Top

Posted by Topache   (2 posts)  Bio
Date Reply #1 on Tue 26 Apr 2005 12:54 AM (UTC)
Message
Dis-regard the Part of the cgi from above. THIS IS THE CORRRECT ONE.. sorry about that.


Part of the cgi:

#!/usr/bin/perl

use strict;

use CGI;

my $cgiobject = new CGI;

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

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

open (MAIL,"|$MailProgram -t") || &errormess;
print MAIL "To: $first\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);
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #2 on Tue 26 Apr 2005 01:20 AM (UTC)

Amended on Tue 26 Apr 2005 01:28 AM (UTC) by Flannel

Message
Disregarding the fact that this is NOT a perl forum (pay more attention to your forums next time, if nothing else, this should have been posted in Programming > General, and it still doesn't fit) but a forum for Perlscripting within Mushclient (a Mud client).

$cgiobject->param("first","second") sets the parameter first to the string "second".
It does NOT return both appended to each other.
So this whole time you've been sending email (or trying) to the "second" email address.
And, you need to make sure you escape BOTH your @'s.

You can (and probably should) read more about CGI.pm here:
http://users.easystreet.com/ovid/cgi_course/appendices/appendix3.html#fetching%20the%20value%20or%20values%20of%20a%20single%20named%20parameter:

And then the header halfway down the page explains what your current code does.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


15,407 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.