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

I'm trying to write a CGI script that emails a user,
displays on a screen in HTML that they received the
email and writes to a log file. When I enter the data
and click on the button nothing happens. I'm highly
confident that my HTML cod is correct. It looks like this:

<form method=POST action='http://learneasymoney.com/cgi-bin/msgout.cgi +'> <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> <input type="hidden" name="subject" value="PPC Traffic & Profits Machi +ne Info"> <input type="hidden" name="owner" value="admin@learneasymoney.com"> <input type="hidden" name="product" value="PPC Traffic & Profits Machi +ne"> <input type="hidden" name="info" value="PPC marketing and how to make +great money with it."> <p align="center"><button type="submit" name="submit" background="#fff +f00" style="font:24pt Arial Black; color:#0000FF;">Get It Now!</butto +n></p> </form>

I reduced the CGI code to this:

#!/usr/bin/perl -wT use strict; use warnings; use CGI ':standard'; open (LOG, "http://learneasymoney.com/logs/optin.txt") || Error('open' +, 'file'); print LOG "This is a test"; close (LOG); print "Content-type: text/html\n\n"; print qq (<html><body bgcolor='#0000FF'>); print qq (<p>&nbsp;); print qq (<p>&nbsp;); print qq (<p>&nbsp;); print qq (<p align='center'>'Hello All!'); print qq (</body></html>); sub Error { print "Content-type: text/html\n\n"; print qq (<html><body bgcolor='#FF0000'>); print qq (<p align='center'>The server can't $_[0] the $_[1]</p>); print qq (<p align='center'>$!</p>); print qq (</body></html>); exit;

The cgi-bin directory and msgout.cgi file permissions are both set to 755.

So what could be going wrong?

(I noticed a couple of red plus signs in my question when I clicked on 'preview'.
When I went back and checked it out, I couldn't find why this was happening).

Replies are listed 'Best First'.
Re: Nothing is happening in my CGI code.
by hippo (Archbishop) on Jul 02, 2013 at 19:49 UTC

    First off, your code doesn't compile:

    $ perl -Tcw /tmp/nuts.pl Missing right curly or square bracket at /tmp/nuts.pl line 25, at end +of line syntax error at /tmp/nuts.pl line 25, at EOF /tmp/nuts.pl had compilation errors.

    Once you've sorted that, you'll need to take another hard look at your open statement and realise that the second argument is a URL, so the open will almost certainly fail.

    Then there's the fact that you are opening (or trying to open) a file for reading and then immediately write to it. That isn't going to work either.

    You also have a use CGI line in there, but it isn't clear to me why you have done that when you are not apparently using any of its features.

    Final tip: don't just guess why your script doesn't work - check the error log on the server.

Re: Nothing is happening in my CGI code.
by tobyink (Canon) on Jul 02, 2013 at 19:18 UTC

    This sub seems to be missing its closing }...

    sub Error {
    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
Re: Nothing is happening in my CGI code. (escapeHTML)
by Anonymous Monk on Jul 02, 2013 at 20:46 UTC

    In addition to what the others said, this  The server can't $_[0] the $_[1] is missing some form of escapeHTML($var)

Re: Nothing is happening in my CGI code.
by Anonymous Monk on Jul 03, 2013 at 13:02 UTC
    Good luck with your pyramid scheme.