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: Re: [davorg] Error Message: Variable "@ADDNEWS" is not imported at ...: Edit Log



Larkdog
User

Jun 27, 2004, 10:37 AM


Views: 3338
Re: [davorg] Error Message: Variable "@ADDNEWS" is not imported at ...

thanks, someone told me it would be better perl writing to have that in there,

so i added it (since i am a beginner)...i am still getting an error message when

running it from the command line, but it scrolls by too fast to read, and I can't

hit the 'pause' button fast enough...

i also want to require a password to this...like have the user enter the password

in the web form, have the script test it, execute the script if true, or display html

page is false, i think is causing my error but i cant read it... its too fast

here is the script updated:


Code
    

#!/usr/bin/perl

use warnings;

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

$|++;

use CGI::Carp qw(fatalsToBrowser);

$addnews_file = '../home.php';

if($ENV{'REQUEST_METHOD'} eq "POST"){

$data_length = $ENV{'CONTENT_LENGTH'};

$bytes_read = read(STDIN, $my_data, $data_length);

}

@name_value_array = split(/&/, $my_data);

foreach $name_value_pair (@name_value_array) {

($name, $value) = split(/=/, $name_value_pair);

$name =~ tr/+/ /;

$value =~ tr/+/ /;

$name =~ s/%(..)/pack("C",hex($1))/eg;

$value =~ s/%(..)/pack("C",hex($1))/eg;

if($form_data{$name})

{

$form_data{$name} .= "\t$value";

}

else

{

$form_data{$name} = $value;

}

}

if($form_data{$password} == 31415926518)

{

open(ADDNEWS, "<$addnews_file") or

die "Can't open ADDNEWS: $addnews_file\n";

@ADDNEWS =<ADDNEWS>;

close(ADDNEWS);

open(ADDNEWS, ">$addnews_file") or

die "Can't open ADDNEWS: $addnews_file\n";

foreach $line (@ADDNEWS){

if($line =~ /<!--Add News:-->/i) {

print ADDNEWS "<!--Add News:-->\n";

print ADDNEWS "<tr><td>\n";

print ADDNEWS "$form_data{'news'}\n";

print ADDNEWS "</td></tr>\n";



} else {

print ADDNEWS "$line";



close(ADDNEWS);







print <<"EOF"

<HTML><TITLE>Entry Submitted</TITLE><HEAD> <META HTTP-EQUIV="refresh" content="4;URL=../home.php"></HEAD><BODY>



<H1>Your News Entry has been Submitted\!</H1>

Your news entry has been successfully added to the

ICE homepage and in <font size=24>3</font> seconds you will be taken back to view it.

</BODY>

EOF

}

else{

print <<"EOF"

<HTML><TITLE>Wrong Password</TITLE><HEAD> <META HTTP-EQUIV="refresh" content="10;URL=../home.php"></HEAD><BODY>



<H1>Wrong Password</H1>

I'm sorry, but you have entered an incorrect password. If you have forgotten your password, send a request for reminder to <a href="mailto:mrlarkins@mrlarkins.com?subject=forgot password">Webmaster</a></BODY>

EOF}

}

#===========================

www.MrLarkins.com

(This post was
edited by Larkdog on Jun 27, 2004, 11:15 AM)


Edit Log:
Post edited by Larkdog (User) on Jun 27, 2004, 11:15 AM


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

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