I've been trying to write a basic contact form but the data isn't getting to the Perl variable I'm trying to use. All I get is an empty string. I'm fairly new to Perl and have been struggling with this for some time now - I don't understand why the code isn't working I tried several different examples I found on the web. It could be my html that's causing the problem? Or could it be the Perl is wrong?
Here is the html for the form:
<form method="post" action="scgi-bin/formhandler.pl" enctype="text/pla
+in">
<p id="invite">Leave Us a Message</p>
<div>
<label for="name">Name:</label>
<input type="text" id="name" />
</div>
<div>
<label for="mail">E-mail:</label>
<input type="email" id="mail" />
</div>
<div>
<label for="message">Message:</label>
<textarea id="message"></textarea>
</div>
<div class="button">
<button type="submit">Send Message</button>
</div>
</form>
and the perl is:
read (STDIN, $in, $ENV{'CONTENT_LENGTH'});
@in = split(/&/, $in);
foreach $i (0 .. $#in)
{
$in[$i] =~ s/\*/ /g;
$in[$i] =~ s/%(..)/pack("c", hex($1))/ge;
($key, $val) = split(/=/, $in[$i],2);
$in{key} .= '\0' if (defined($in{$key}));
$in{key} .= $val;
}
I checked and $in is getting no data, it's just an empty string - why? Utterly confused!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.