Re: Preview data

2002-04-12 Thread Kris G Findlay

ok exact problem !!

Example data inputed via form :
'here is a quote  this Quote.'   # which is passes to variable $document

if i use hidden fields in a html form to store these variables while the
page displays a preview
eg  print input type=\hidden\ name=\hiddenField\ value=\$document\

the html page returned displays corectly and all data is in source
eg  input type=hidden name=hiddenField value=here is a quote  this
Quote.
but when form is submited to cgi the data after the extra quote mark is
missing

the only solution i could think of was to replace the  in the data with '
but in an attempt to preserve data
integrity is there another solution.

if not how can i apply a regex to replace  with ' to all data wich is
retrieved using CGI module.

---
Kris G Findlay

- Original Message -
From: Nikola Janceski [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, April 12, 2002 2:18 PM
Subject: RE: Preview data


 uh... Are you using the CGI module?

 This test CGI script can take 'hello  what?'
 and when submitted will return the exact same thing.
 What kinda problem are you really having?

 #!perl
 use strict;
 use warnings;
 use CGI qw(:standard);
 print header();
 if(param()){
 print param('crap'), p();

 } else {
 print start_form();

 print textfield(-name ='crap',
 -size = 30), p();
 print submit(), p();
 print end_form();
 }
 __END__

  -Original Message-
  From: drieux [mailto:[EMAIL PROTECTED]]
  Sent: Friday, April 12, 2002 9:04 AM
  To: [EMAIL PROTECTED]
  Subject: Re: Preview data
 
 
 
  On Friday, April 12, 2002, at 04:30 , Kris G Findlay wrote:
 
   i'm writing a script that takes data submited by a form and
  adds it to a
   mysql database
   but i would like to be able to preview the data as it is to
  be displayed
   before final submission to database. i have tried using hidden form
   fields within a prieview page
   but have a problem of these fields breacking when a  is
  included within
   the data
 
  I ran into that as well What I had to do was write around it
 
 
  #--
  # a simple step forward to allow for Andy R expressions
  # a bit of overkill and all...
 
  sub dtk_retArray {
 
   my ($string) = @_;
   my @list;
 
   if ( $string =~ /.*/ ) {
   my $tmp = $string;
   while ( $tmp ) {
   if ( $tmp =~ s/^([\w\s]*)\s*(.*)/$1 $2/) {
   $tmp = $2;
   push(@list, $1);
   } elsif ($tmp =~ s/(\w*)\s*(.*)/$1 $2/) {
   $tmp = $2;
   push(@list, $1);
   }
   }
 
   } else {
@list = split(' ', $string);
   }
 
   @list;
 
  } # end of dtk_retArray
 
 
  I called that to check how a given textField had been set and
  whether or not it had  marks  - the twisted part was noticing
  that the way I had written the inner perl stuff meant that I
  could write 'perl syntax' pattern matching
 
  eg: search for Andy R or Andy\s*R 
 
 
  ciao
  drieux
 
  ---
 
 
  --
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 

 --
--
 
 The views and opinions expressed in this email message are the sender's
 own, and do not necessarily represent the views and opinions of Summit
 Systems Inc.


 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Preview data

2002-04-12 Thread Nikola Janceski

again.. you should have used the CGI module... it would have no problems
with that.

#!perl
use strict;
use warnings;
use CGI qw(:standard);

print header();
if(param()){

print param('crap'), p();

} else {
print start_form();
my $crap = 'here is a quote  this Quote.';
print Hidden file: $crap;
print hidden(-name ='crap',
-value = $crap);

print submit(), p();
print end_form();

}
__END__

This script seems to have no trouble with that...


 -Original Message-
 From: Kris G Findlay [mailto:[EMAIL PROTECTED]]
 Sent: Friday, April 12, 2002 10:16 AM
 To: beginners; cgi
 Subject: Re: Preview data
 
 
 ok exact problem !!
 
 Example data inputed via form :
 'here is a quote  this Quote.'   # which is passes to 
 variable $document
 
 if i use hidden fields in a html form to store these 
 variables while the
 page displays a preview
 eg  print input type=\hidden\ name=\hiddenField\ 
 value=\$document\
 
 the html page returned displays corectly and all data is in source
 eg  input type=hidden name=hiddenField value=here is a 
 quote  this
 Quote.
 but when form is submited to cgi the data after the extra 
 quote mark is
 missing
 
 the only solution i could think of was to replace the  in 
 the data with '
 but in an attempt to preserve data
 integrity is there another solution.
 
 if not how can i apply a regex to replace  with ' to all data wich is
 retrieved using CGI module.
 
 ---
 Kris G Findlay
 
 - Original Message -
 From: Nikola Janceski [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Friday, April 12, 2002 2:18 PM
 Subject: RE: Preview data
 
 
  uh... Are you using the CGI module?
 
  This test CGI script can take 'hello  what?'
  and when submitted will return the exact same thing.
  What kinda problem are you really having?
 
  #!perl
  use strict;
  use warnings;
  use CGI qw(:standard);
  print header();
  if(param()){
  print param('crap'), p();
 
  } else {
  print start_form();
 
  print textfield(-name ='crap',
  -size = 30), p();
  print submit(), p();
  print end_form();
  }
  __END__
 
   -Original Message-
   From: drieux [mailto:[EMAIL PROTECTED]]
   Sent: Friday, April 12, 2002 9:04 AM
   To: [EMAIL PROTECTED]
   Subject: Re: Preview data
  
  
  
   On Friday, April 12, 2002, at 04:30 , Kris G Findlay wrote:
  
i'm writing a script that takes data submited by a form and
   adds it to a
mysql database
but i would like to be able to preview the data as it is to
   be displayed
before final submission to database. i have tried using 
 hidden form
fields within a prieview page
but have a problem of these fields breacking when a  is
   included within
the data
  
   I ran into that as well What I had to do was write around it
  
  
   #--
   # a simple step forward to allow for Andy R expressions
   # a bit of overkill and all...
  
   sub dtk_retArray {
  
my ($string) = @_;
my @list;
  
if ( $string =~ /.*/ ) {
my $tmp = $string;
while ( $tmp ) {
if ( $tmp =~ 
 s/^([\w\s]*)\s*(.*)/$1 $2/) {
$tmp = $2;
push(@list, $1);
} elsif ($tmp =~ s/(\w*)\s*(.*)/$1 $2/) {
$tmp = $2;
push(@list, $1);
}
}
  
} else {
 @list = split(' ', $string);
}
  
@list;
  
   } # end of dtk_retArray
  
  
   I called that to check how a given textField had been set and
   whether or not it had  marks  - the twisted part was noticing
   that the way I had written the inner perl stuff meant that I
   could write 'perl syntax' pattern matching
  
   eg: search for Andy R or Andy\s*R 
  
  
   ciao
   drieux
  
   ---
  
  
   --
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
 
  
 --
 
 --
  
  The views and opinions expressed in this email message are 
 the sender's
  own, and do not necessarily represent the views and 
 opinions of Summit
  Systems Inc.
 
 
  --
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Preview data

2002-04-12 Thread Kris G Findlay

exellent Jenda .. thats spot on.

exactly what i was looking for. 

thanx to you all for your help it was much apreciated 

-
Kris G Findlay
http://www.knight-shift.com

- Original Message - 
From: Jenda Krynicky [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, April 12, 2002 3:55 PM
Subject: Re: Preview data


 From: drieux [EMAIL PROTECTED]
  On Friday, April 12, 2002, at 07:15 , Kris G Findlay wrote:
  
   ok exact problem !!
  
   Example data inputed via form :
   'here is a quote  this Quote.' # which is passes to variable
   $document
  
   if i use hidden fields in a html form to store these variables while
   the page displays a preview eg  print input type=\hidden\
   name=\hiddenField\ value=\$document\ 
  
   the html page returned displays corectly and all data is in source
   eg  input type=hidden name=hiddenField value=here is a quote 
   this Quote. but when form is submited to cgi the data after the
   extra quote mark is missing
  
  [..]
  
  $hiddenField = param('hiddenField');
  
  $hiddenField =~ s/\/\\\/g; # \\ - insert \ and \ guard my 
  
  which I think would work 
 
 No it will not.
 
 The  should be replaced by quot; or #34;.
 
 This is the safest method:
 
 use HTML::Entities;
 $hiddenField = encode_entities(param('hiddenField'));
 
 $html = qq{input type=hidden name=something 
 value=$hiddenfield};
 
 Jenda
 
 === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
 There is a reason for living. There must be. I've seen it somewhere.
 It's just that in the mess on my table ... and in my brain
 I can't find it.
 --- me
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Preview data

2002-04-12 Thread drieux


On Friday, April 12, 2002, at 04:30 , Kris G Findlay wrote:

 i'm writing a script that takes data submited by a form and adds it to a 
 mysql database
 but i would like to be able to preview the data as it is to be displayed
 before final submission to database. i have tried using hidden form 
 fields within a prieview page
 but have a problem of these fields breacking when a  is included within 
 the data

I ran into that as well What I had to do was write around it


#--
# a simple step forward to allow for Andy R expressions
# a bit of overkill and all...

sub dtk_retArray {

 my ($string) = @_;
 my @list;

 if ( $string =~ /.*/ ) {
 my $tmp = $string;
 while ( $tmp ) {
 if ( $tmp =~ s/^([\w\s]*)\s*(.*)/$1 $2/) {
 $tmp = $2;
 push(@list, $1);
 } elsif ($tmp =~ s/(\w*)\s*(.*)/$1 $2/) {
 $tmp = $2;
 push(@list, $1);
 }
 }

 } else {
  @list = split(' ', $string);
 }

 @list;

} # end of dtk_retArray


I called that to check how a given textField had been set and
whether or not it had  marks  - the twisted part was noticing
that the way I had written the inner perl stuff meant that I
could write 'perl syntax' pattern matching

eg: search for Andy R or Andy\s*R 


ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Preview data

2002-04-12 Thread Nikola Janceski

uh... Are you using the CGI module?

This test CGI script can take 'hello  what?'
and when submitted will return the exact same thing.
What kinda problem are you really having?

#!perl
use strict;
use warnings;
use CGI qw(:standard);
print header();
if(param()){
print param('crap'), p();

} else {
print start_form();

print textfield(-name ='crap',
-size = 30), p();
print submit(), p();
print end_form();
}
__END__

 -Original Message-
 From: drieux [mailto:[EMAIL PROTECTED]]
 Sent: Friday, April 12, 2002 9:04 AM
 To: [EMAIL PROTECTED]
 Subject: Re: Preview data
 
 
 
 On Friday, April 12, 2002, at 04:30 , Kris G Findlay wrote:
 
  i'm writing a script that takes data submited by a form and 
 adds it to a 
  mysql database
  but i would like to be able to preview the data as it is to 
 be displayed
  before final submission to database. i have tried using hidden form 
  fields within a prieview page
  but have a problem of these fields breacking when a  is 
 included within 
  the data
 
 I ran into that as well What I had to do was write around it
 
 
 #--
 # a simple step forward to allow for Andy R expressions
 # a bit of overkill and all...
 
 sub dtk_retArray {
 
  my ($string) = @_;
  my @list;
 
  if ( $string =~ /.*/ ) {
  my $tmp = $string;
  while ( $tmp ) {
  if ( $tmp =~ s/^([\w\s]*)\s*(.*)/$1 $2/) {
  $tmp = $2;
  push(@list, $1);
  } elsif ($tmp =~ s/(\w*)\s*(.*)/$1 $2/) {
  $tmp = $2;
  push(@list, $1);
  }
  }
 
  } else {
   @list = split(' ', $string);
  }
 
  @list;
 
 } # end of dtk_retArray
 
 
 I called that to check how a given textField had been set and
 whether or not it had  marks  - the twisted part was noticing
 that the way I had written the inner perl stuff meant that I
 could write 'perl syntax' pattern matching
 
 eg: search for Andy R or Andy\s*R 
 
 
 ciao
 drieux
 
 ---
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Preview data

2002-04-12 Thread drieux


On Friday, April 12, 2002, at 07:15 , Kris G Findlay wrote:

 ok exact problem !!

 Example data inputed via form :
 'here is a quote  this Quote.' # which is passes to variable 
 $document

 if i use hidden fields in a html form to store these variables while the
 page displays a preview
 eg  print input type=\hidden\ name=\hiddenField\ value=\$document\
 

 the html page returned displays corectly and all data is in source
 eg  input type=hidden name=hiddenField value=here is a quote  this
 Quote.
 but when form is submited to cgi the data after the extra quote mark is
 missing

[..]

$hiddenField = param('hiddenField');

$hiddenField =~ s/\/\\\/g; # \\ - insert \ and \ guard my 

$document = $hiddenField ;

hence your print would now output:

input type=hidden name=hiddenField value=here is a quote  \this 
Quote\.

which I think would work 
And would retain the this Quote in the hidden field - as a CGI
but would also need to be 'deconstructed upon return


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Preview data

2002-04-12 Thread Jenda Krynicky

From: drieux [EMAIL PROTECTED]
 On Friday, April 12, 2002, at 07:15 , Kris G Findlay wrote:
 
  ok exact problem !!
 
  Example data inputed via form :
  'here is a quote  this Quote.' # which is passes to variable
  $document
 
  if i use hidden fields in a html form to store these variables while
  the page displays a preview eg  print input type=\hidden\
  name=\hiddenField\ value=\$document\ 
 
  the html page returned displays corectly and all data is in source
  eg  input type=hidden name=hiddenField value=here is a quote 
  this Quote. but when form is submited to cgi the data after the
  extra quote mark is missing
 
 [..]
 
 $hiddenField = param('hiddenField');
 
 $hiddenField =~ s/\/\\\/g; # \\ - insert \ and \ guard my 
 
 which I think would work 

No it will not.

The  should be replaced by quot; or #34;.

This is the safest method:

use HTML::Entities;
$hiddenField = encode_entities(param('hiddenField'));

$html = qq{input type=hidden name=something 
value=$hiddenfield};

Jenda

=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain
I can't find it.
--- me

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Preview data

2002-04-12 Thread drieux


On Friday, April 12, 2002, at 07:55 , Jenda Krynicky wrote:

 No it will not.

just figured that out
[..]
 This is the safest method:

   use HTML::Entities;
   $hiddenField = encode_entities(param('hiddenField'));

   $html = qq{input type=hidden name=something
 value=$hiddenfield};

 Jenda

I think I also support Nikola Janceski in that the problem
really needs to be done using CGI.pm - vice trying to hand
craft the lines..

since his illustration generated:

input type=hidden name=crap value=here is a quote  quot;this Quote
quot;. /input type=submit name=.submit /

I'm a bit concerned about:

input type=hidden name=crap value=here is a quote  amp;quot;this 
Quoteamp;quot;. /

which is what comes out of

#!perl
use strict;
use warnings;
use CGI qw(:standard);
use HTML::Entities

print header();

 my $crap = 'here is a quote  this Quote.';

my  $hiddenField = encode_entities($crap);
 print hidden(-name ='crap',
 -value = $hiddenField);

so there appears to be a double evaluation that would occur going
this way - vice a straight shot of how yours went:

input type=hidden name=something value=here is a quote  quot;this Quote
quot;.


ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Preview data

2002-04-12 Thread Jenda Krynicky

From: drieux [EMAIL PROTECTED]
 On Friday, April 12, 2002, at 07:55 , Jenda Krynicky wrote:
 
  No it will not.
 
 just figured that out
 [..]
  This is the safest method:
 
  use HTML::Entities;
  $hiddenField = encode_entities(param('hiddenField'));
 
  $html = qq{input type=hidden name=something
  value=$hiddenfield};
 
  Jenda
 
 I think I also support Nikola Janceski in that the problem
 really needs to be done using CGI.pm - vice trying to hand
 craft the lines..

Yes, if you can use that I fully agree you should, but if you have 
some html template you fill in you have to make sure you escape 
your data yourself :-)

But of course as always you have to make sure you do not quote 
twice ... but that's a smaller bug since that's easier to find :-)

Jenda

=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain
I can't find it.
--- me

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Preview data

2002-04-12 Thread drieux


On Friday, April 12, 2002, at 08:41 , Jenda Krynicky wrote:
[..]
 Yes, if you can use that I fully agree you should, but if you have
 some html template you fill in you have to make sure you escape
 your data yourself :-)

the horrors of 'maintaining' code that should have started with
CGI.pm to have begun with Keep kobbling, we do not have time
to go back and fix the root cause problem

 But of course as always you have to make sure you do not quote
 twice ... but that's a smaller bug since that's easier to find :-)

why does this sound like G. Spencer Brown's The law of forms???

It would seem that the current CGI.pm should not
retranslation of quot; into amp;quot; - or am I being naive?

Also, while I like Nikola's generalized solution - I have
decided that the general idea of

$page_o_html .= things that add onto it

allows me to be more flexible so that I can 'dump out' the
page at different stages  as I try to figure out what this
or that Module gives me as 'features' for doing CGI/mod_perl
stuff




ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Preview data

2002-04-12 Thread Jenda Krynicky

From: drieux [EMAIL PROTECTED]
 It would seem that the current CGI.pm should not
 retranslation of quot; into amp;quot; - or am I being naive?

If CGI.pm would be made by Microsoft then it would not. And if you 
needed to put into a hidden field something that already is HTML 
it'll screw things up.

Keep in mind that the user might have entered those quot;, lt; 
B and others. So if you want them to survive you have to escape 
them. Even if that would mean the page will contain

input type=hidden name=foo value=1 amp;lt; 2

if the user entered
1 lt; 2

Jenda

=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain
I can't find it.
--- me

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Preview data

2002-04-12 Thread Nikola Janceski

And why can't you do the same with the CGI module?
$page_o_html = hidden(-name = 'crap', -value = $crap);
would be the same thing.

You lost me on that... plus if you really need to, I have ADDED the CGI at a
later point to a pre-existing script and only change the portions that I
really wanted to use CGI.pm (cause it's better) and left the rest of the
code as is (cause it was too cumbersome to change it all). But then the code
starts looking ugly, at some point it needed a re-write (2 months later).
I don't use the CGI or HTML modules for tables, I prefer to write those
myself, but never had problems with throwing in my own html code in with the
CGI stuff.

 -Original Message-
 From: drieux [mailto:[EMAIL PROTECTED]]
 Sent: Friday, April 12, 2002 12:18 PM
 To: [EMAIL PROTECTED]
 Subject: Re: Preview data
 
 Also, while I like Nikola's generalized solution - I have
 decided that the general idea of
 
   $page_o_html .= things that add onto it
 
 allows me to be more flexible so that I can 'dump out' the
 page at different stages  as I try to figure out what this
 or that Module gives me as 'features' for doing CGI/mod_perl
 stuff
 
 
 
 
 ciao
 drieux



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Preview data

2002-04-12 Thread drieux


On Friday, April 12, 2002, at 09:51 , Jenda Krynicky wrote:
[..]
 Keep in mind that the user might have entered those quot;, lt;
 B and others. So if you want them to survive you have to escape
 them. Even if that would mean the page will contain

   input type=hidden name=foo value=1 amp;lt; 2

 if the user entered
   1 lt; 2

YIKES!

what is the perl module for 'fix broken end user'?

Or is this more a problem of using the 'hidden' approach
for carrying state information from one invokation to
the next???

Given the original concern to 'retain' the This Quote in the
hidden field, there is now the problem of decode_entities perchance
more than once???

original input: This Quote
saved as hidden: $quot;This Quote$quot;

so the

$hiddenValue = param('hiddenValue');

would return it as

This Quote or as '$quot;This Quote$quot;'

???

ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Preview data

2002-04-12 Thread Jenda Krynicky

From:   drieux [EMAIL PROTECTED]
 Given the original concern to 'retain' the This Quote in the
 hidden field, there is now the problem of decode_entities perchance
 more than once???
 
  original input: This Quote
  saved as hidden: $quot;This Quote$quot;
 
 so the
 
  $hiddenValue = param('hiddenValue');
 
 would return it as
 
  This Quote or as '$quot;This Quote$quot;'
 
 ???

The first of course.

Jenda

=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain
I can't find it.
--- me

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




One Print, One WebPage was Re: Preview data

2002-04-12 Thread drieux


On Friday, April 12, 2002, at 10:05 , Nikola Janceski wrote:

 And why can't you do the same with the CGI module?
 $page_o_html = hidden(-name = 'crap', -value = $crap);
 would be the same thing.

 You lost me on that...

Mea Kulpa...

essential it's the case of
s/print/$page_o_html .=/

and then have a single print at the end

[..]

so much of the documentation about using CGI seems to be of the form

print 
print..

and I feel safer with say

print $page_o_html ;

with only one 'print' event - I still have the old fear of
I/O costs

hence we started with the boring definition

my $page_o_html = '';

and go through the steps of building it up

$page_o_html .= header;

$page_o_html .= hidden(-name = 'crap', -value = $crap);


$page_o_html .= end_html;

This way I can add 'subs' where appropriate, do the name space
isolation and I do not have to worry about the fact that
somewhere around line X we started a print

But this may be the luxury of not being specifically obliged
to maintain code that was not started this way I stole this
trick from some CGI stuff from '99 () and just thought it made much
better sense.

Not sure I agree with you about building tables by hand But
I am sure your experience offers you the case work to recommend it
as the simpler to maintain...

ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Preview data

2002-04-12 Thread Kris G Findlay

ok exact problem !!

Example data inputed via form :
'here is a quote  this Quote.'   # which is passes to variable $document

if i use hidden fields in a html form to store these variables while the
page displays a preview
eg  print input type=\hidden\ name=\hiddenField\ value=\$document\

the html page returned displays corectly and all data is in source
eg  input type=hidden name=hiddenField value=here is a quote  this
Quote.
but when form is submited to cgi the data after the extra quote mark is
missing

the only solution i could think of was to replace the  in the data with '
but in an attempt to preserve data
integrity is there another solution.

if not how can i apply a regex to replace  with ' to all data wich is
retrieved using CGI module.

---
Kris G Findlay

- Original Message -
From: Nikola Janceski [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, April 12, 2002 2:18 PM
Subject: RE: Preview data


 uh... Are you using the CGI module?

 This test CGI script can take 'hello  what?'
 and when submitted will return the exact same thing.
 What kinda problem are you really having?

 #!perl
 use strict;
 use warnings;
 use CGI qw(:standard);
 print header();
 if(param()){
 print param('crap'), p();

 } else {
 print start_form();

 print textfield(-name ='crap',
 -size = 30), p();
 print submit(), p();
 print end_form();
 }
 __END__

  -Original Message-
  From: drieux [mailto:[EMAIL PROTECTED]]
  Sent: Friday, April 12, 2002 9:04 AM
  To: [EMAIL PROTECTED]
  Subject: Re: Preview data
 
 
 
  On Friday, April 12, 2002, at 04:30 , Kris G Findlay wrote:
 
   i'm writing a script that takes data submited by a form and
  adds it to a
   mysql database
   but i would like to be able to preview the data as it is to
  be displayed
   before final submission to database. i have tried using hidden form
   fields within a prieview page
   but have a problem of these fields breacking when a  is
  included within
   the data
 
  I ran into that as well What I had to do was write around it
 
 
  #--
  # a simple step forward to allow for Andy R expressions
  # a bit of overkill and all...
 
  sub dtk_retArray {
 
   my ($string) = @_;
   my @list;
 
   if ( $string =~ /.*/ ) {
   my $tmp = $string;
   while ( $tmp ) {
   if ( $tmp =~ s/^([\w\s]*)\s*(.*)/$1 $2/) {
   $tmp = $2;
   push(@list, $1);
   } elsif ($tmp =~ s/(\w*)\s*(.*)/$1 $2/) {
   $tmp = $2;
   push(@list, $1);
   }
   }
 
   } else {
@list = split(' ', $string);
   }
 
   @list;
 
  } # end of dtk_retArray
 
 
  I called that to check how a given textField had been set and
  whether or not it had  marks  - the twisted part was noticing
  that the way I had written the inner perl stuff meant that I
  could write 'perl syntax' pattern matching
 
  eg: search for Andy R or Andy\s*R 
 
 
  ciao
  drieux
 
  ---
 
 
  --
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 

 --
--
 
 The views and opinions expressed in this email message are the sender's
 own, and do not necessarily represent the views and opinions of Summit
 Systems Inc.


 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Preview data

2002-04-12 Thread Nikola Janceski

again.. you should have used the CGI module... it would have no problems
with that.

#!perl
use strict;
use warnings;
use CGI qw(:standard);

print header();
if(param()){

print param('crap'), p();

} else {
print start_form();
my $crap = 'here is a quote  this Quote.';
print Hidden file: $crap;
print hidden(-name ='crap',
-value = $crap);

print submit(), p();
print end_form();

}
__END__

This script seems to have no trouble with that...


 -Original Message-
 From: Kris G Findlay [mailto:[EMAIL PROTECTED]]
 Sent: Friday, April 12, 2002 10:16 AM
 To: beginners; cgi
 Subject: Re: Preview data
 
 
 ok exact problem !!
 
 Example data inputed via form :
 'here is a quote  this Quote.'   # which is passes to 
 variable $document
 
 if i use hidden fields in a html form to store these 
 variables while the
 page displays a preview
 eg  print input type=\hidden\ name=\hiddenField\ 
 value=\$document\
 
 the html page returned displays corectly and all data is in source
 eg  input type=hidden name=hiddenField value=here is a 
 quote  this
 Quote.
 but when form is submited to cgi the data after the extra 
 quote mark is
 missing
 
 the only solution i could think of was to replace the  in 
 the data with '
 but in an attempt to preserve data
 integrity is there another solution.
 
 if not how can i apply a regex to replace  with ' to all data wich is
 retrieved using CGI module.
 
 ---
 Kris G Findlay
 
 - Original Message -
 From: Nikola Janceski [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Friday, April 12, 2002 2:18 PM
 Subject: RE: Preview data
 
 
  uh... Are you using the CGI module?
 
  This test CGI script can take 'hello  what?'
  and when submitted will return the exact same thing.
  What kinda problem are you really having?
 
  #!perl
  use strict;
  use warnings;
  use CGI qw(:standard);
  print header();
  if(param()){
  print param('crap'), p();
 
  } else {
  print start_form();
 
  print textfield(-name ='crap',
  -size = 30), p();
  print submit(), p();
  print end_form();
  }
  __END__
 
   -Original Message-
   From: drieux [mailto:[EMAIL PROTECTED]]
   Sent: Friday, April 12, 2002 9:04 AM
   To: [EMAIL PROTECTED]
   Subject: Re: Preview data
  
  
  
   On Friday, April 12, 2002, at 04:30 , Kris G Findlay wrote:
  
i'm writing a script that takes data submited by a form and
   adds it to a
mysql database
but i would like to be able to preview the data as it is to
   be displayed
before final submission to database. i have tried using 
 hidden form
fields within a prieview page
but have a problem of these fields breacking when a  is
   included within
the data
  
   I ran into that as well What I had to do was write around it
  
  
   #--
   # a simple step forward to allow for Andy R expressions
   # a bit of overkill and all...
  
   sub dtk_retArray {
  
my ($string) = @_;
my @list;
  
if ( $string =~ /.*/ ) {
my $tmp = $string;
while ( $tmp ) {
if ( $tmp =~ 
 s/^([\w\s]*)\s*(.*)/$1 $2/) {
$tmp = $2;
push(@list, $1);
} elsif ($tmp =~ s/(\w*)\s*(.*)/$1 $2/) {
$tmp = $2;
push(@list, $1);
}
}
  
} else {
 @list = split(' ', $string);
}
  
@list;
  
   } # end of dtk_retArray
  
  
   I called that to check how a given textField had been set and
   whether or not it had  marks  - the twisted part was noticing
   that the way I had written the inner perl stuff meant that I
   could write 'perl syntax' pattern matching
  
   eg: search for Andy R or Andy\s*R 
  
  
   ciao
   drieux
  
   ---
  
  
   --
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
 
  
 --
 
 --
  
  The views and opinions expressed in this email message are 
 the sender's
  own, and do not necessarily represent the views and 
 opinions of Summit
  Systems Inc.
 
 
  --
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Preview data

2002-04-12 Thread Kris G Findlay

exellent Jenda .. thats spot on.

exactly what i was looking for. 

thanx to you all for your help it was much apreciated 

-
Kris G Findlay
http://www.knight-shift.com

- Original Message - 
From: Jenda Krynicky [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, April 12, 2002 3:55 PM
Subject: Re: Preview data


 From: drieux [EMAIL PROTECTED]
  On Friday, April 12, 2002, at 07:15 , Kris G Findlay wrote:
  
   ok exact problem !!
  
   Example data inputed via form :
   'here is a quote  this Quote.' # which is passes to variable
   $document
  
   if i use hidden fields in a html form to store these variables while
   the page displays a preview eg  print input type=\hidden\
   name=\hiddenField\ value=\$document\ 
  
   the html page returned displays corectly and all data is in source
   eg  input type=hidden name=hiddenField value=here is a quote 
   this Quote. but when form is submited to cgi the data after the
   extra quote mark is missing
  
  [..]
  
  $hiddenField = param('hiddenField');
  
  $hiddenField =~ s/\/\\\/g; # \\ - insert \ and \ guard my 
  
  which I think would work 
 
 No it will not.
 
 The  should be replaced by quot; or #34;.
 
 This is the safest method:
 
 use HTML::Entities;
 $hiddenField = encode_entities(param('hiddenField'));
 
 $html = qq{input type=hidden name=something 
 value=$hiddenfield};
 
 Jenda
 
 === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
 There is a reason for living. There must be. I've seen it somewhere.
 It's just that in the mess on my table ... and in my brain
 I can't find it.
 --- me
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]