in reply to Re: Not getting form data from stdin
in thread Not getting form data from stdin

Yeah, stop right there, don't write any more code, read TFMail, study it, study the functions it uses ... if you're going to start in the past at least start with something that works :) and these FAQs (a copy of a copy paste)
This copy/paste is for you :) esp the first bold link (then all the rest)

You basically need work through the checklists (do what each item says, if it solves the problem GREAT, if it doesn't move on to NEXT item), brian's Guide to Solving Any Perl Problem, CGI Help Guide , Troubleshooting Perl CGI scripts ... More generic advice :) On debugging, verify everything, talk to teddybear ... checklists and more

Because https://httpd.apache.org/docs/2.2/howto/public_html.html#cgi / Apache Tutorial: Dynamic Content with CGI and more

Copy/paste from Re: To call a .pl file when a button is pressed on a GUI created using Perl CGI (webserver) for the links below

Its simple, you need a webserver

Why? Because webpages and CGI needs a webserver, thats how it works

Its weird that so many folks manage to create a GUI using Perl CGI without understanding this

learn about the internet,Web Programming: For Beginners, to get an overall picture of how the internet works, how tcp/ip, sockets, html, ajax, all fit together....

See also Mojolicious::Lite +and jQuery +AJAX + Mojo::Template

And a copy-pasta for you:)

Also, there are checklists for that , Basic debugging checklist , brian's Guide to Solving Any Perl Problem, CGI Help Guide , Troubleshooting Perl CGI scripts

Yes, work through these checklists, when you find a problem on the list, use a solution from the list, when you find a problem not on the list (rare), post the error message and problem description here

brian's Guide to Solving Any Perl Problem, CGI Help Guide , Troubleshooting Perl CGI scripts

So examine your server configuration and compare to https://httpd.apache.org/docs/2.2/howto/public_html.html#cgi / Apache Tutorial: Dynamic Content with CGI

learn about the internet,Web Programming: For Beginners, to get an overall picture of how the internet works, how tcp/ip, sockets, html, ajax, all fit together.

Explicitly using Options to permit CGI execution, Apache Tutorial: Dynamic Content with CGI - Apache HTTP Server Version 2.2 : Explicitly using Options to permit CGI execution

... let the deep links from the following explain Re: Cron revisited/Re^2: Perl Module Not Working In Crontab explain, and here they are:

  • Comment on Re^2: Not getting form data from stdin (nms-cgi)

Replies are listed 'Best First'.
Re^3: Not getting form data from stdin (nms-cgi)
by trewornan (Initiate) on Nov 06, 2014 at 12:16 UTC

    Right - so far I've got:

    sub parse { my $q = new CGI; print $q->header; print '<html><head>'; print '<title>Test</title>'; print '</head><body>'; print "These are the parameters I received:<p>"; my( $name, $value ); foreach $name ( $q->param ) { print "$name:\n"; foreach $value ( $q->param( $name ) ) { print " $value\n"; } } print '</p></body></html>'; }

    Unfortunately the output is:

    These are the parameters I received: POSTDATA:

    So really not much progress. However since it seems I've been going about this all wrong maybe just best to leave that and start over from the beginning with TFMail. Feeling somewhat discouraged.

      Add name to inputs in html form
      <input type="text" id="name" name="name" /> -----------
      poj

        Ahh - so simple. Thank you superdoc.

        I now have a working script. Unfortunately couldn't use TFMal because I don't have permission for sendmail. I ended up with the following. Probably a bit clunky but it works.

        #! /usr/bin/perlml use Mail::Sendmail; use CGI; @values=(); &parse; &send; &thanks; sub parse { my $q = new CGI; my $data = $q->param('POSTDATA'); @values = split (/[\s=]+/, $data); } sub send { $mail{'smtp'} = "smtp.###.co.za"; $mail{'port'} = 465; $mail{'auth'} = {user => '###@###.co.za', password => '###'}; %mail = ( To => '###@###.co.za', From => "@values[3]", Message => "@values[1]\n\n@values[5]" ); sendmail(%mail) or die $Mail::Sendmail::error; } sub thanks { print "Content-type: text/html \n\n"; print <<END; <html> <head> <title>Thank you for your message</title> <meta http-equiv="Content-Type" content="text/html; c +harset=utf-8" /> <meta http-equiv="Content-Language" content="en" /> <link rel="stylesheet" type="text/css" href="/css/gen +eral.css" /> <link rel="stylesheet" type="text/css" href="/css/tha +nks.css" /> </head> <body> <div id="header"> <img id="small-logo" alt="### Logo" src="/graphic +s/LogoSmall.jpg" height="80" width="80" /> <div id="nav"> <ul> <li><a href="/index.html">home</a></li> <li><a href="/about.html">about us</a></l +i> <li><a href="/products.html">products</a> +</li> <li><a href="/customers.html">customers</ +a></li> <li><a href="/gallery.html">gallery</a></ +li> <li><a href="/contact.html">contact us</a +></li> </ul> </div> </div> <div id="content"> <h1>Thank you for leaving a message</h1> <p>We will respond as soon as possible.</p> </div> </body> </html> END }