So what we're gonna do is to make our script read this line, and split
it up so we can print out the name.
(*fval) = @_ if @_ ;
local ($buf);
if ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN,$buf,$ENV{'CONTENT_LENGTH'}); }
else { $buf=$ENV{'QUERY_STRING'}; };
if ($buf eq "") { return 0; }
else
{
@myarray = split(/&/,$buf);
foreach $i @myarray
{
($Crap,$Name) = split(/=/,$i);
$NewVar{$crap} = $name;
};
};
Don't worry about all this ... it just gets the line and splits it up. What you
can see is that first it splits up the line between & signs .. because if
there were several vars in the line it would look like this: hello.pl?name=woody&age=23&street=fakestreet
that's why it does that. It puts all these text between & sign into the array
@myarray, so @myarray would hold @myarray("name=woody","age=23,"street=fakestreet")
But in this case it only contains name and woody. So now it splits up
the "name=woody" into name and woody, so $crap would hold "name" and $name
would hold "woody". So if we should print out the name, we should write
print $NewVar{'name'}; easy ?
So the only thing left is to display the name for the user:
print " Content-type: text/html\n\n";
print "< html >\n" ;
print "< head >\n" ;
print " < title >hello test< /title >\n" ;
print "< /head >\n" ;
print "\n" ;
print "< body >\n" ;
print "Hello ",$NewVar{'name'}," .. welcome to my site\n";
print "< /body >< /html >\n";
That was easy right ? ;) Next time maybe I'll make some file and procedure
routines for you. That's all folks :)
wOODY^dRN