CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
AHHHHHHH!!!!!!!

 



mattmatt
Deleted

Jul 31, 2000, 11:31 AM

Post #1 of 6 (463 views)
AHHHHHHH!!!!!!! Can't Post

this is ****ing me off so bad, i know it's F*CKIN easy but i CANT GET IT TO WORK!! ahhhhh!!!

ok here it is... im doing a web-based email thing and when someone goes to their addresses, they can add people to their list then when they check off peoples names and click submit it takes them to a compose page where they can write mail and it has the peoples names they chose in the "to" field... but the problem is, it doesnt send the information from the checkboxes to the script!! i named it "to" and gave it a value of the person's name that it corresponds with, and i made the right form action and method, what can i do??!!

im all out of ideas, the only thing that MIGHT be it is, well.. here look:

<form action="/cgi-bin/sendad.cgi" method=POST><input type=hidden name=name value=$name><input type=hidden name=pass value=$pass>
<table border=1 colspan=2 width=100% cellspacing=3>
<td align=center bgcolor=red> <b> <font face=arial size=3 color=white> To: </b> </TD>
<td align=center bgcolor=red> <b> <font face=arial size=3 color=white> Name: </b> </TD><tr>


<td align=center><input type="checkbox" name="to" value=ThePimpMatt></TD><td align=left><font face=verdana color=0066E1 size=3><b> ThePimpMatt </b></TD><TR>
<td align=center><input type="checkbox" name="to" value=BlingBling></TD><td align=left><font face=verdana color=0066E1 size=3><b> BlingBling </b></TD><TR>

</tr></table><br><table width=100%><tr><td width=50% align=center><input type=submit name=submit value=Send></td></tr></table></form>

CAN ANYONE TELL ME IF THERES ANYTHING WRONG THERE OF WHAT MIGHT BE GOING WRONG WITH IT??

oh wait, heres the script that it send all of the info to:

#!/bin/perl

sub Parse_Form {the sub goes here but i know thats not the prob.
}
&Parse_Form;

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

$name = $formdata{'name'};
$pass = $formdata{'pass'};
$to = $formdata{'to'};
@sendto = split(/,/, $to);
#############################################

then to test it out, i try printing the names BUT THEY DONT PRINT OUT!

im sorry this is so long but please help me!!!!

THANK YOU SO MUCH



Kanji
User / Moderator

Jul 31, 2000, 12:14 PM

Post #2 of 6 (463 views)
Re: AHHHHHHH!!!!!!! [In reply to] Can't Post

 <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">quote:</font><HR>sub Parse_Form {the sub goes here but i know thats not the prob.sub Parse_Form {the sub goes here but i know thats not the prob.<HR></BLOCKQUOTE>

How do you know? What is the value of $formdatat{'to'}? What's the value of @sendto? Where do the commas you're splitting on come from?

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

use CGI;

$name = param('name');
$pass = param('pass');
@sendto = param('to'); # Yup, its an array.</pre><HR></BLOCKQUOTE>

Does the same thing happen if you use that instead?


mattmatt
Deleted

Jul 31, 2000, 1:20 PM

Post #3 of 6 (463 views)
Re: AHHHHHHH!!!!!!! [In reply to] Can't Post

well the reason i know why its not the problem is because ive used it tons of times before and never had a problem with it...

the value of $to is "ThePimpMatt" and "BlingBling", and because theres two values i put them into an array by splitting them, ive tried just sayin @sendto = $formdata{'to'}; but that didnt work so i tried the split thing

ok ill go try the code you put up
oh yeah, do i have to use the "use CGI;" thing??

thanks!


mattmatt
Deleted

Jul 31, 2000, 1:34 PM

Post #4 of 6 (463 views)
Re: AHHHHHHH!!!!!!! [In reply to] Can't Post

well i just now tried it, it didnt work either

do u know what else could be going wrong??
i know theres tons of things i could be doing wrong

thanks,
matt


Kanji
User / Moderator

Jul 31, 2000, 3:26 PM

Post #5 of 6 (463 views)
Re: AHHHHHHH!!!!!!! [In reply to] Can't Post

Without seeing the script in question, its hard to say ... you omit so much of it, there's no telling if the problem lies elsewhere.

Anyway, if I'm reading you right, $formdate{'to'} contains both "ThePimpMatt" and "BlingBling" (but you fail to say what the entire string is), but @sendto contains nothing?

That leads me to think you've left out more code because $sendto[0] should be -- at the very least -- the same as $formdata{'to'}.

Perhaps you can post your script somewhere?


mattmatt
Deleted

Aug 1, 2000, 10:40 PM

Post #6 of 6 (463 views)
Re: AHHHHHHH!!!!!!! [In reply to] Can't Post

yeah ill post it up right here...

#!/bin/perl

sub Parse_Form {
if ($ENV{'REQUEST_METHOD'} eq 'GET' ) {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);

if ($ENV{'QUERY_STRING'}) {
@getpairs =split(/&/, $ENV{'QUERY_STRING'});
push(@pairs, @getpairs);
}
} else {
print "Content-type: text/html\n\n";
print "<p>Use Post or Get";
}

foreach $pair (@pairs) {
($key, $value) = split (/=/, $pair);
$key =~ tr/+/ /;
$key =~ s/%([a-fA-F0-9][a-fA-F0-9])
/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])
/pack("C", hex($1))/eg;

if ($formdata{$key}) {
$formdata{$key} .= ", $value";
} else {
$formdata{$key} = $value;
}
}
1;
}
&Parse_Form;

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


$logsdir = "../../logs/";

$name = $formdata{'name'};
$pass = $formdata{'pass'};


$nameads = $logsdir . $name . "ads" . "\.txt";


open(LOG, "<$nameads");
@ads = <LOG>;
close(LOG);


print <<"HTML code";

<html>
<head>

<title> Mail Center Addresses </TITLE>

<style> <!--a:hover {color:silver) --> </style>

</head>

<body bgcolor=black link=0066E1 alink=grape vlink=red>

<center> <img src=\"/mn_imgs/mail_ad1.jpg\"> </center>

<br><br>

<form action=\"/cgi-bin/sendad.cgi\" method=POST><input type=hidden name=name value=$name><input type=hidden name=pass value=$pass>
<table border=1 colspan=2 width=100\% cellspacing=3>
<td align=center bgcolor=red> <b> <font face=arial size=3 color=white> To: </b> </TD>
<td align=center bgcolor=red> <b> <font face=arial size=3 color=white> Name: </b> </TD><tr>

HTML code

############ right below here i print each address, heres what it is like:
<td align=center><input type=\"checkbox\" name=\"to\" value=$addname></TD><td align=left><font face=verdana color=0066E1 size=3><b> $addname </b></TD><TR>\n
#############################

foreach $ad (@ads) {
print "$ad";
}


print "
</tr></table><br><table width=100\%><tr><td width=50\% align=center><input type=submit name=submit value=Send></td></tr></table></form>
<br> <table border=0 width=100\% colspan=2>

<tr><td align=right width=50\%></td><td align=center width=50\%><font face=Verdana color=white>Add Name</font></td></tr>
<tr><td align=center width=50\%></td>
<td align=center width=50\%><font face=arial color=white size=3> <b> Name to Add: </b><form action=\"/cgi-bin/adname.cgi\" method=POST><input type=hidden name=name value=$name><input type=hidden name=pass value=$pass><input type=\"text\" name=\"addname\"><br><input type=submit name=submit value=\"Add Name\"></form></TD>
</tr></table>

</body></html>";


#############################################
there it is, do u see anything wrong with it?

thanks,
Matt

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives