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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enter problems

Status
Not open for further replies.

TyzA

Programmer
Jan 7, 2002
86
BE
Hi,

I have this form on my HTML page, used for contact.
They have to enter a name, email address and their comment.

When they click the submit button, a CGI (Perl) script checkes the format of the mail. If this format is not OK, they can choose to go back and modify their email address. Herefor I parse the value I retrieved from the form for the comment back to the contact page, so they don't have to retype it.

The problem I have now is that when you type your text with some enters in the text area, I parse it to the cgi script which will loose all the enter characters, .... When the email address is incorrect, Parse the some parameter back to the contact page as the value for that text area. But now I've lost all my enters, sosome words are concattenated now.

Hope you can help me,

Tijs Programming is like sex: one mistake and you have to support it for the rest of your life.
 
Can you post a concise version of the code? 'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
This is the code with what I read in the parameters received from the form:

sub cgidecode
{
local(%vars, $val, $key, $last, $buffer, $pair, @pairs);

# Checking the form method (GET or POST) used in the
# HTML code. POST method sends data to standard input,
# but GET adds it to the URL and stores it in
# QUERY_STRING.
if ($ENV{'REQUEST_METHOD'} eq "POST")
{
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
}
else
{
$buffer = $ENV{'QUERY_STRING'};
}
# Splitting up the data fields and store
# in array @pairs, they are seperated with &
@pairs = split(/&/, $buffer);

# Splitting the variable names and the values
# and storing them in the assoc. array %vars
foreach $pair (@pairs)
{
($key, $val) = split(/=/, $pair);
$val =~ s/\+/ /g;
$val =~ s/%(..)/pack("C",hex($1))/eg;
if ($key eq $last) {$vars{$key} .= " ".$val; }
else { $vars{$key} = $val; }
$last = $key;
}
return(%vars);
}

Example of commment:
Test now with the enter
here is the enter
here again

When clicked on the submit button, this is what is parsed to the cgi script:

feedback_contact.cgi?naam=&emailadress=&comment=Test+now+with+the+enter%0D%0Ahere+is+the+enter%0D%0Ahere+again&zend=Zend


So I have this piece of code that checks the email address. If it's wrong, the user can choose to go back and correct his email address. To go back, I call the page the following way:

<a href=\&quot;contact.cgi?naam=$naam&emailadress=&comment=$comment\&quot;>

And I put it like this in the textarea:

<textarea cols=&quot;50&quot; rows=&quot;6&quot; name=&quot;comment&quot; class=&quot;form&quot;> $comment1</textarea>

where $comment1 is the variable I read in from the parsed parameters with the same piece of code as above.

What i get now in the textarea is:

Test now with the enterhere is the enterhere again

I just lost the enters.

Do you know a way to prevent this.

Thanks a lot for helpin'
Programming is like sex: one mistake and you have to support it for the rest of your life.
 
I think all you need to do is use 'wrap=hard' in your html textarea tag. That tells the browser to maintain any hard returns in the text.
Code:
<textarea .....   wrap=&quot;hard&quot;>default content</textarea>
'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Hi goBoating,

Sorry, but it doesn't help Programming is like sex: one mistake and you have to support it for the rest of your life.
 
$comment
$comment1
?
whats the diference ?
have u change the value of the original &quot;passed&quot; $comment ? ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
$comment is the value of the comment parameter I parse from the form to the script.

So when the email address is incorrect, I parse $comment back as the value for the variable comment:

<a href=\&quot;contact.cgi?naam=$naam&emailadress=&comment=$comment\&quot;>


Then I read in the parsed parameters with that piece of code and put the value of comment into $comment1:

my $comment1 = %FORM{'comment'};

After this I put $comment1 as the value of the textarea:

<textarea cols=&quot;50&quot; rows=&quot;6&quot; name=&quot;comment&quot; class=&quot;form&quot;> $comment1</textarea>

When i do it like this, I loose all my enters

Hope this is any better,

Thanks

Programming is like sex: one mistake and you have to support it for the rest of your life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top