[JaxPM] Code Help

CGR Online cgronline at jaxcan.org
Sat Jan 20 15:16:18 CST 2001


On the jacksonville-pm-list; Jax.PM'er CGR Online <cgronline at jaxcan.org> wrote -

UGH. I need help.  Here is a sample of my code. What it is supposed to do
is this. From a web page (see code belwo) you type in either a mobile
telephone number or an E-mail address or both. What it is supposed to do
then is select a random line from a flat file and send it via e-mail to
either the e-mail address entered by the user or their mobile phone number
@ptel.net. 

Okay, so what's wrong is this. The mobile number works fine. Tested many
times. If you don't type anything in either field, it goes to an error
with is fine also. However when you put the e-mail address it sill gives
the same error as though there was no e-mail address given. At the end of
the error sub code you can see I had it print out the variables to make
sure they were getting filled and it is!! that's confusing me. So here is
the HTML

---snip---
<HTML> <TITLE>Send a Verse</TITLE>

<body bgcolor="black" text="white" vlink="green">

<CENTER><a href="http://www.christiangamers.org"><IMG
SRC="http://www.christiangamers.org/goldenic.gif" border=0> click to
return</a></CENTER> <FORM
ACTION="http://alpha.jaxcan.org/~cgronline/vs/randv.cgi">

Enter Your Mobile Number:<input name="mobile"> <BR> or <BR> You can enter
your e-mail address:<input name="email"> <BR> <input type=submit
value=Finished> <input type=reset value=Reset>

<center>The mobile section is for Powertel Users who have Mobile
E-mail</center>
---snip---

Now here is the perl code

---snip---
#!/usr/bin/perl use CGI;
use diagnostics;
use CGI::Carp 'fatalsToBrowser'; 

$q = new CGI; 

#$mail=$q->escapeHTML( $q->param('mail'));
my $mobile=$q->escapeHTML( $q->param('mobile'));
my $sendmail="/usr/sbin/sendmail";
my $email=$q->escapeHTML( $q->param('email')); my $blank = ""; 

#### Randomize the Line ####
open(FH, "<verse.txt");
rand($.) < 1 and ($line = $_) while <FH>; close(FH); 

if ($mobile == $blank) { 
	&error;
	exit;
}

### Send to Mobile ###
$sufix="\@ptel.net";
open(MAIL, "|$sendmail -t") || die "Coundn't do it $!\n";
print MAIL "To:$mobile$sufix\n";
print MAIL "Subject:\n";
print MAIL "$line\n";
close(MAIL); 

print "Content-Type: text/html\n\n";
print "<body bgcolor=\"black\" text=\"white\" vlink=\"green\">";
print "The following has been sent to your phone.<BR>";
print "<B>$line<BR></B>";
print "<FORM><INPUT TYPE=\"BUTTON\" NAME=\"GOBACK\" VALUE=\"BACK\"
OnClick=\"history.go(-1)\"></FORM><BR>\n"; 

sub email { 
### Send to e-mail ###
open(MAIL, "|$sendmail -t") || die "Coundn't do it $!\n";
print MAIL "To: $email\n";
print MAIL "Subject:\n"; 
print MAIL "$line\n";
close(MAIL); 

print "Content-Type: text/html\n\n";
print "<body bgcolor=\"black\" text=\"white\" vlink=\"green\">";
print "The following has been sent to your phone.<BR>";
print "<B>$line<BR></B>"; print "<FORM><INPUT TYPE=\"BUTTON\"
NAME=\"GOBACK\" VALUE=\"BACK\" OnClick=\"history.go(-1)\"></FORM><BR>\n";
}

sub error {
if ($email != $blank) {
	&email;
	exit;
}
else {
print "Content-Type: text/html\n\n";
print "Sorry, you must enter something for it to work\n";
print "<BR>Click on the back button<BR>";
print "m : $mobile<BR>";
print "e : $email\n";
}
}
---snip---

This is the third re-write of the code. The first two handled the if
statements differently but all had the exact same results. For example

if (($mobile == $blank) && ($email == $blank)) { &error;  exit;  } elsif
($mobile != $blank) 

and so on and so forth.... 

Any Idea? HELP ME OBI WAN KANOBI Your my only hope.



Jax.PM Moderator's Note:
This message was posted to the Jacksonville Perl Monger's Group listserv.
The group manager can be reached at -- owner-jacksonville-pm-list at pm.org
to whom send all praises, complaints, or comments...




More information about the Jacksonville-pm mailing list