Loading ...
Sorry, an error occurred while loading the content.

Is something wrong with mailme.pl file

Expand Messages
  • Dinh Nguyen
    Hi, I am running into a problem when it says that the variable is not initialized... http://koiparade.netfirms.com/mailme.html
    Message 1 of 3 , Jun 1, 2004
    • 0 Attachment
      Hi,

      I am running into a problem when it says that the variable is not
      initialized...
      http://koiparade.netfirms.com/mailme.html
      http://koiparade.netfirms.com/cgi/cgierr.pl/cgi-bin/mailme.pl

      Does anyone know what's going on? Please let me know when you have a
      moment.
      The source code is from the link below:
      http://www.devarticles.com/c/a/Perl/Perl-101-The-email-form/4/
      Thanks,
      DN
    • Charles K. Clarkson
      ... The script was written to demonstrate a beginning perl program. It will only run when called from the form in the first link above. Calling it directly
      Message 2 of 3 , Jun 1, 2004
      • 0 Attachment
        Dinh Nguyen <mailto:dhnguyen89821@...> wrote:

        : I am running into a problem when it says that the variable
        : is not initialized... http://koiparade.netfirms.com/mailme.html
        : http://koiparade.netfirms.com/cgi/cgierr.pl/cgi-bin/mailme.pl
        :
        : Does anyone know what's going on? Please let me know when
        : you have a moment. The source code is from the link below:
        : http://www.devarticles.com/c/a/Perl/Perl-101-The-email-form/4/

        The script was written to demonstrate a beginning perl
        program. It will only run when called from the form in the
        first link above. Calling it directly (from the second
        link) yields the error you are referring to.

        The error exists because there is no check for a value
        in the form fields:

        $name = $q->param("name");
        $email = $q->param("email");
        $message = $q->param("message");

        When called from a blank form using 'method="get"' the url
        is sent as:

        http://localhost/cgi-bin/mailme.pl?name=&amail=&message=

        When the CGI.pm module encounters this it reports an empty
        value for 'name', 'email', and 'message'. When sent without
        any parameters it returns 'undef' for those values. This is
        what happens when you click on the second link you provide
        above. You can fix this by providing for a default value.

        my $name = $q->param("name") || '';
        my $email = $q->param("email") || '';
        my $message = $q->param("message") || '';



        Please note that the script is only intended for use from
        a form. In production the script would require additional error
        checking to be complete. Also note that the article is only an
        introduction to perl. The author seems to have deliberately
        left out many important steps to create good perl scripts.

        DO NOT USE THIS SCRIPT on your web site as is. Learn more
        about programming in perl and about security for CGI and
        internet programming and then re-write this script or use the
        TFMail script available from nms-scripts.

        http://nms-cgi.sourceforge.net/

        For additional articles on perl programming checkout
        Randal's articles at:

        http://www.stonehenge.com/merlyn/


        HTH,

        Charles K. Clarkson
        --
        Mobile Homes Specialist
        254 968-8328
      • Dinh Nguyen
        Hi Charles, Thanks for quick response. I am just testing the file (this will not go to production, it s much more complicated on the server) and it seems like
        Message 3 of 3 , Jun 2, 2004
        • 0 Attachment
          Hi Charles,

          Thanks for quick response. I am just testing the file (this will not
          go to production, it's much more complicated on the server) and it
          seems like the error occur when at the line "die;" so when the
          variable is null then the script dies.

          unless ($name =~ /^[\w ]/)
          {
          print "Oops you entered your name incorrectly - please go back and
          check it<br>";
          die;
          }

          http://koiparade.netfirms.com/cgi/cgierr.pl/cgi-bin/mailme.pl

          Is there something else I need to do to overcome this?

          Thanks,
          DN

          --- In perl-beginner@yahoogroups.com, "Charles K. Clarkson"
          <cclarkson@h...> wrote:
          > Dinh Nguyen <mailto:dhnguyen89821@y...> wrote:
          >
          > : I am running into a problem when it says that the variable
          > : is not initialized... http://koiparade.netfirms.com/mailme.html
          > : http://koiparade.netfirms.com/cgi/cgierr.pl/cgi-bin/mailme.pl
          > :
          > : Does anyone know what's going on? Please let me know when
          > : you have a moment. The source code is from the link below:
          > : http://www.devarticles.com/c/a/Perl/Perl-101-The-email-form/4/
          >
          > The script was written to demonstrate a beginning perl
          > program. It will only run when called from the form in the
          > first link above. Calling it directly (from the second
          > link) yields the error you are referring to.
          >
          > The error exists because there is no check for a value
          > in the form fields:
          >
          > $name = $q->param("name");
          > $email = $q->param("email");
          > $message = $q->param("message");
          >
          > When called from a blank form using 'method="get"' the url
          > is sent as:
          >
          > http://localhost/cgi-bin/mailme.pl?name=&amail=&message=
          >
          > When the CGI.pm module encounters this it reports an empty
          > value for 'name', 'email', and 'message'. When sent without
          > any parameters it returns 'undef' for those values. This is
          > what happens when you click on the second link you provide
          > above. You can fix this by providing for a default value.
          >
          > my $name = $q->param("name") || '';
          > my $email = $q->param("email") || '';
          > my $message = $q->param("message") || '';
          >
          >
          >
          > Please note that the script is only intended for use from
          > a form. In production the script would require additional error
          > checking to be complete. Also note that the article is only an
          > introduction to perl. The author seems to have deliberately
          > left out many important steps to create good perl scripts.
          >
          > DO NOT USE THIS SCRIPT on your web site as is. Learn more
          > about programming in perl and about security for CGI and
          > internet programming and then re-write this script or use the
          > TFMail script available from nms-scripts.
          >
          > http://nms-cgi.sourceforge.net/
          >
          > For additional articles on perl programming checkout
          > Randal's articles at:
          >
          > http://www.stonehenge.com/merlyn/
          >
          >
          > HTH,
          >
          > Charles K. Clarkson
          > --
          > Mobile Homes Specialist
          > 254 968-8328
        Your message has been successfully submitted and would be delivered to recipients shortly.