Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Nothing is being written into my opt-in.txt file

by bgatto (Initiate)
on Jul 10, 2013 at 20:39 UTC ( [id://1043558]=perlquestion: print w/replies, xml ) Need Help??

bgatto has asked for the wisdom of the Perl Monks concerning the following question:

Hello All,

I'm running an HTML form on a web hostthat looks like this:

<form method=POST action="http://learneasymoney.com/cgi-bin/sendinfo.c +gi"> <b><font face="arial" size=5 color="#ffffff"> Name: <input type="text" name="fullname" size=35><br> &nbsp;eMail: <input type="text" name="email" size=35> </b></font> <p align="center"><input type="submit" name="submit" background="#ffff +00" value="Get It Now" style="font:24pt Arial Black; color:#0000FF;"> +</p> </form>

The code for sendinfo.cgi is:

#!/usr/bin/perl -w use strict; my $sendto = param('email'); my $sendname = param('name'); open (LOG, ">>http://learneasymoney.com/Logs/opt-in.txt") || die("Erro +r: " . $!); print LOG $sendname . "," . $sendto . \n; close (LOG);

When I enter my name and email address and click the submit button, I get sent back to the original web site and I get an error. When I go and check the opt-in.txt file, I find nothing in the file. What is going wrong?

Replies are listed 'Best First'.
Re: Nothing is being written into my opt-in.txt file
by Illuminatus (Curate) on Jul 10, 2013 at 20:57 UTC
    1. Your html says 'fullname', but your script is looking for just 'name'
    2. Can you run sendinfo.cgi on the server (modified to take it's params from the cmdline) and have it do what you expect?
    3. If (2) works, make sure the user the webserver is running your script as has permission to do what you want

    fnord

Re: Nothing is being written into my opt-in.txt file
by thomas895 (Deacon) on Jul 10, 2013 at 22:55 UTC

    You're all missing the root of the problem:

    open (LOG, ">>http://learneasymoney.com/Logs/opt-in.txt") || die("Erro +r: " . $!);

    Something there is wrong, but can you see it?

    You cannot open a URL like that, you must find the path of the file on disk.
    ~Thomas~ 
    "Excuse me for butting in, but I'm interrupt-driven..."

      Excellent, and the second thing that is wrong is failure to check the server logs, where STDERR would have recorded the die message.


      Dave

Re: Nothing is being written into my opt-in.txt file
by hippo (Bishop) on Jul 10, 2013 at 21:31 UTC

    Your code doesn't compile:

    $ perl -cw /tmp/nuts2.pl Bareword "n" not allowed while "strict subs" in use at /tmp/nuts2.pl l +ine 9. /tmp/nuts2.pl had compilation errors.

    Haven't we been through this before? Why did you not try to compile the script yourself? Why did you not try looking in the error log?

Re: Nothing is being written into my opt-in.txt file
by poj (Abbot) on Jul 10, 2013 at 21:42 UTC
    Use this as your cgi, it will show you what is wrong
    #!/usr/bin/perl -w use strict; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); my $sendto = param('email'); my $sendname = param('fullname'); #my $logfile = 'http://learneasymoney.com/Logs/opt-in.txt'; my $logfile = '/tmp/opt-in.txt'; my $msg; if ( open LOG, '>>',$logfile ) { print LOG "$sendname,$sendto\n"; close (LOG); $msg = "$sendname $sendto written to $logfile"; } else { $msg = "File open Error: ".$!; } print header(),start_html() ,p($msg) ,a({-href=>'easy.html'},'return') ,end_html();
    poj

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1043558]
Approved by davido
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-20 00:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found