[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Perlscript
. . -> [Subject]  Please Need help grabbing 2 variables - cgi

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Please Need help grabbing 2 variables - cgi

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Topache   (2 posts)  [Biography] bio
Date Tue 26 Apr 2005 12:49 AM (UTC)  quote  ]
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);

[Go to top] top

Posted by Topache   (2 posts)  [Biography] bio
Date Reply #1 on Tue 26 Apr 2005 12:54 AM (UTC)  quote  ]
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);
[Go to top] top

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

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.
[Go to top] 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.


1,875 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]