in reply to Re^2: Not getting form data from stdin (nms-cgi)
in thread Not getting form data from stdin

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.

Replies are listed 'Best First'.
Re^4: Not getting form data from stdin (nms-cgi)
by poj (Abbot) on Nov 06, 2014 at 13:07 UTC
    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 }
        Why are you using POSTDATA? Here is unclunky version
        #!/usr/bin/perlml -- ## ## ## ## perltidy -olq -csc -csci=3 -cscl="sub : BEGIN END " -otr -opr -ce +-nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr +-ce -nibc -i=4 -pt=0 "-nsak=*" ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if while " -otr + -opr -ce -nibc -i=4 -pt=0 "-nsak=*" #!/usr/bin/perl -- use strict; use warnings; use CGI (); use CGI::Carp qw( fatalsToBrowser ); use Mail::Sendmail qw/ sendmail /; Main( @ARGV ); exit( 0 ); sub Main { my $q = CGI->new; ## NONSENSE ## my @values = split /[\s=]+/, $q->param('POSTDATA'); #~ Send( split /[\s=]+/, $q->param('POSTDATA') ); Send( $q ); return print Thanks( $q ); } sub Send { my( $q ) = @_; my $from = $q->param( 'from' ); my $msg = $q->param( 'msg' ); my %mail = ( 'smtp' => "smtp.###.co.za", 'port' => 465, 'auth' => { user => '###@###.co.za', password => '###' }, To => '###@###.co.za', From => $from, Message => $msg, ); sendmail( %mail ) or die $Mail::Sendmail::error; } ## end sub Send sub Thanks { return $cgi->header, <<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 } ## end sub Thanks __END__