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:
Another problem...

 



SaiyanM
User

Feb 5, 2001, 6:30 PM

Post #1 of 5 (715 views)
Another problem... Can't Post

This code works, kinda. It wont write to one of my files, and I need help on this... if you know, please help

#!/usr/bin/perl
&Parse;
######################################################################
######################################################################
# DO NOT EDIT THIS FILE. IT IS VERY IMPORTANT THAT IT'S NOT TOUCHED #
######################################################################
######################################################################
######################################################################
######################################################################
# DO NOT EDIT THIS FILE. IT IS VERY IMPORTANT THAT IT'S NOT TOUCHED #
######################################################################
######################################################################
######################################################################
######################################################################
# DO NOT EDIT THIS FILE. IT IS VERY IMPORTANT THAT IT'S NOT TOUCHED #
######################################################################
######################################################################
$FILE = "/cgi-bin/guestbook/gbooklog.txt";


open(FILE, ">>".$FILE);

$name = $values{"name"};
$email = $values{"email"};
$url = $values{"url"};
$feedback= $values{"feedback"};

print FILE<<STOP;
<tr>
<td width="11%"><center>$name</center></td>
<td width="26%"><center><font face="arial">$e-mail</center></td>
<td width="24%"><center><font face="arial">$url</font></center></td>
<td width="39%"><center><font face="arial">$feedback</font></center></td>
</tr>
STOP
close(FILE);


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

Thanks For Your Entry. Here is what You have Added:

- NAME: $name

- E_MAIL: $e-mail

- URL: $url

- FEEDBACK: $feedback

<Br> <a href="/cgi-bin/guestbook/gbooklog.txt">View The Guestbook</a>
<Br>
kaiosama
exit 0;


sub emailmember {
open(MAIL,"|$mailp -t");
print MAIL "To: $email\n";
print MAIL "From: SaiyanM\@hotmail.com\n";
print MAIL "Subject: You Signed my guestbook\n\n";
print MAIL "Thanks for signing guestbook\n\n";
print MAIL "\n\n";
close (MAIL);
}


sub Parse
{
local($fields, $name, $value, $data);


read(STDIN, $data, $ENV{"CONTENT_LENGTH"});
@fields = split(/&/, $data);

foreach $item(@fields)
{

($name, $value) = split(/=/, $item);
$name = &unescape($name);
$value =&unescape($value);

$values{$name} = $value;
}
}

sub unescape
{
local($s) = $_[0];
local($pos, $ascii);

$s =~ s/\+/ /g;

$pos = 0;
while(($pos = index($s, "%", $pos)) != -1)
{
$ascii = hex(substr($s, $pos + 1, 2));
substr($s, $pos, 3) = pack("c", $ascii);
}
$s;
}



pu_nk
journeyman

Feb 5, 2001, 6:48 PM

Post #2 of 5 (710 views)
Re: Another problem... [In reply to] Can't Post

 

I would try changing the following code ...

------------------------------------------------------
open(FILE, ">>".$FILE);

$name = $values{"name"};
$email = $values{"email"};
$url = $values{"url"};
$feedback= $values{"feedback"};

print FILE<<STOP;
<tr>
<td width="11%"><center>$name</center></td>
<td width="26%"><center><font face="arial">$e-mail</center></td>
<td width="24%"><center><font face="arial">$url</font></center></td>
<td width="39%"><center><font face="arial">$feedback</font></center></td>
</tr>
STOP
close(FILE);
-------------------------------------------------------------

To somthing like so.....

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

$name = $values{"name"};
$email = $values{"email"};
$url = $values{"url"};
$feedback= $values{"feedback"};

open(FILE, ">>$FILE");
print FILE "<tr>\n";
print FILE "<td width=\"11%\"><center>$name</center></td>\n";
print FILE "<td width=\"26%\"><center><font face=\"arial\">$e-mail</center></td>\n";
print FILE "<td width=\"24%\"><center><font face=\"arial\">$url</font></center></td>\n";
print FILE "<td width=\"39%\"><center><font face=\"arial\">$feedback</font></center></td>\n";
print FILE "</tr>\n";
close(FILE);

hope this helps.




pu_nk
journeyman

Feb 5, 2001, 6:53 PM

Post #3 of 5 (710 views)
Re: Another problem... [In reply to] Can't Post

Also.. i would put the FULL PATH to the file you are calling here..
$FILE = "/cgi-bin/guestbook/gbooklog.txt";


something like... ( example )
$FILE = "/home/www//cgi-bin/guestbook/gbooklog.txt";






SaiyanM
User

Feb 6, 2001, 4:17 AM

Post #4 of 5 (702 views)
Re: Another problem... [In reply to] Can't Post

I now get this error from the error log...

syntax error at guestbook3.cgi line 68, near "print"
In string, @hotmail now must be written as \@hotmail at guestbook3.cgi line 68, near "@hotmail"
syntax error at guestbook3.cgi line 101, near "print"
Missing right bracket at guestbook3.cgi line 143, at end of line
syntax error at guestbook3.cgi line 143, at EOF
Execution of guestbook3.cgi aborted due to compilation errors.




muinatit
Deleted

Feb 6, 2001, 12:44 PM

Post #5 of 5 (695 views)
Re: Another problem... [In reply to] Can't Post

You probably removed the \ in front of the @ where you sent off the email. Put it back in as the error said. This might cover for the rest of the errors as well.

muinatit
muinatit@hotpop.com

 
 


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

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