Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help with form submission

Status
Not open for further replies.

vkarthik

Programmer
Aug 30, 2001
126
US
This is my problem:

I have a textarea in a form, and the form will submit to a perl script (passing the value in this textarea). I find that when I type somethin in the textarea with an indentation (say, i press enter twice between 2 lines), these 'enter' (or '\n') characters are not retained when the perl script receives it.

so im not able to show the text the way it was typed originally.

any useful thoughts on this will get nice votes. LOL A ship is safe in the harbour, but that's not what it is meant for!!! LOL
 
call this script testline.pl and put in in the cgi-bin
#!/usr/local/bin/perl

print "Content-type: text/html\n\n";

# Read and 'decode' the data received by the server so that
# we can use it in our HTML.
if ($ENV{'REQUEST_METHOD'} eq "get") { $buffer = $ENV{'QUERY_STRING'}; }
else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); }
@nvpairs = split(/&/, $buffer);
foreach $pair (@nvpairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/\n/\n<br>/g;#Makes a visual line in html
$FORM{$name} = $value;
}

##Create the HTML with the 'decoded' data plugged in.


print &quot;<HTML>\n&quot;;
print &quot;<HEAD>\n&quot;;
print &quot;<TITLE>Multilene textarea</TITLE>\n&quot;;
print &quot;</HEAD>\n&quot;;
print &quot;<BODY BGCOLOR=\&quot;\#FFFF80\&quot; TEXT=\&quot;\#000000\&quot;>\n&quot;;
print &quot;<BASEFONT SIZE=4>\n&quot;;
print &quot;<CENTER>\n&quot;;
print &quot;$FORM{'TEST'}!\n&quot;;
print &quot;</CENTER>\n&quot;;
print &quot;</BODY>\n&quot;;
print &quot;</HTML>\n&quot;;


and take this as html:

<html><head><title>test</title></head>
<body>
<FORM METHOD=&quot;POST&quot; ACTION=&quot;/cgi-bin/testline.pl&quot;>
<textarea name=&quot;TEST&quot;></textarea>
<input type=submit>
</form></body></html>


 
thanks! will try it out and get back. LOL A ship is safe in the harbour, but that's not what it is meant for!!! LOL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top