Re: [PHP] validating textarea using php

2008-05-14 Thread Dotan Cohen
2008/5/14 Richard Heyes <[EMAIL PROTECTED]>:
> That really should be expected. You can't expect something to last forever
> without tweaking it on occassion.  And in the case of going from PHP 5 - 6,
> the "tweaking" required may well be major, becxcause it's a major version
> change.

Exactly. That's why it should be written in a relatively portable
fashion from the beginning. To avoid pitfalls later on.

>> A year is nothing! I have projects from 7 years ago that I know I need
>> to update "when I get around to it".
>
> Well "when you get around to it" makes it sound as though it's not exactly
> important.
>

It was written in a relatively portable fashion.

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?


Re: [PHP] validating textarea using php

2008-05-14 Thread Richard Heyes

Dotan Cohen wrote:

2008/5/14 Richard Heyes <[EMAIL PROTECTED]>:

 Any host that upgrades the PHP version (a major upgrade considering it
would be 5 - 6) without notifying Customers isn't a very good hosting
company, and you really should change to a better one (Rackspace are good).
Even 1and1 don't do that and they're pants (IMO).


It does not matter if the customer was notified. Even if he is
notified, he needs to update his code.


That really should be expected. You can't expect something to last 
forever without tweaking it on occassion.  And in the case of going from 
PHP 5 - 6, the "tweaking" required may well be major, becxcause it's a 
major version change.



 Plus you need to consider how long they would take to use PHP6 exclusively
- my guess it would be at least a year; probably longer.


A year is nothing! I have projects from 7 years ago that I know I need
to update "when I get around to it".


Well "when you get around to it" makes it sound as though it's not 
exactly important.


--
Richard Heyes

++
| Access SSH with a Windows mapped drive |
|http://www.phpguru.org/sftpdrive|
++

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] validating textarea using php

2008-05-14 Thread Dotan Cohen
2008/5/14 Richard Heyes <[EMAIL PROTECTED]>:
>  Any host that upgrades the PHP version (a major upgrade considering it
> would be 5 - 6) without notifying Customers isn't a very good hosting
> company, and you really should change to a better one (Rackspace are good).
> Even 1and1 don't do that and they're pants (IMO).

It does not matter if the customer was notified. Even if he is
notified, he needs to update his code.

>  Plus you need to consider how long they would take to use PHP6 exclusively
> - my guess it would be at least a year; probably longer.

A year is nothing! I have projects from 7 years ago that I know I need
to update "when I get around to it".

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?


Re: [PHP] validating textarea using php

2008-05-14 Thread Richard Heyes

A lot of people think that


Can't fault them.

> until their host upgrades php.

Any host that upgrades the PHP version (a major upgrade considering it 
would be 5 - 6) without notifying Customers isn't a very good hosting 
company, and you really should change to a better one (Rackspace are 
good). Even 1and1 don't do that and they're pants (IMO).


Plus you need to consider how long they would take to use PHP6 
exclusively - my guess it would be at least a year; probably longer.


> Have you

seen how many things are being removed for php6?


Nope. Why? It's not even out yet in beta and therefore not worth my time 
considering. ISTR having read something about a 5.3 release, which I 
read would have namespaces. That needs consideration before any PHP6 
release.


--
Richard Heyes

++
| Access SSH with a Windows mapped drive |
|http://www.phpguru.org/sftpdrive|
++

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] validating textarea using php

2008-05-14 Thread Dotan Cohen
2008/5/14 Chris W <[EMAIL PROTECTED]>:
>> A lot of people think that, until their host upgrades php. Have you
>> seen how many things are being removed for php6?
>
> From the article I read, that isn't one of them.
>

That issue specifically, no. However, portable code is desirable even
if your code is confined to a single machine.

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?


Re: [PHP] validating textarea using php

2008-05-13 Thread Chris W

Dotan Cohen wrote:

2008/5/14 Richard Heyes <[EMAIL PROTECTED]>:

It also makes the code less portable.

If that's even a concern. A lot of the time, it's not.



A lot of people think that, until their host upgrades php. Have you
seen how many things are being removed for php6?


From the article I read, that isn't one of them.


--
Chris W
KE5GIX

"Protect your digital freedom and privacy, eliminate DRM,
learn more at http://www.defectivebydesign.org/what_is_drm";

Ham Radio Repeater Database.
http://hrrdb.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] validating textarea using php

2008-05-13 Thread Robert Cummings

On Wed, 2008-05-14 at 00:32 +0300, Dotan Cohen wrote:
> 2008/5/14 Richard Heyes <[EMAIL PROTECTED]>:
> >> It also makes the code less portable.
> >
> > If that's even a concern. A lot of the time, it's not.
> >
> 
> A lot of people think that, until their host upgrades php. Have you
> seen how many things are being removed for php6?

PHP6??? Pshaw... PHP5 just came out the other week ;D

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] validating textarea using php

2008-05-13 Thread Dotan Cohen
2008/5/14 Richard Heyes <[EMAIL PROTECTED]>:
>> It also makes the code less portable.
>
> If that's even a concern. A lot of the time, it's not.
>

A lot of people think that, until their host upgrades php. Have you
seen how many things are being removed for php6?

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?


Re: [PHP] validating textarea using php

2008-05-13 Thread Richard Heyes

Jim Lucas wrote:

Richard Heyes wrote:
Also you can use short tags (popular...) to make the HTML more 
readable. Eg:








It also makes the code less portable.


If that's even a concern. A lot of the time, it's not.

--
Richard Heyes

++
| Access SSH with a Windows mapped drive |
|http://www.phpguru.org/sftpdrive|
++

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] validating textarea using php

2008-05-13 Thread Shawn McKenzie

Dan Joseph wrote:

On Tue, May 13, 2008 at 12:02 PM, Usamah al-Amin <[EMAIL PROTECTED]>
wrote:


 if(chop($comments) == "") { ... }   //hope that helps.

Well, chop() is an alias of rtrim(), so it won't work here for, say,
trimming control characters at the end of the string like line feeds.

trim() is actually the best bit here.

Regards,
Usamah

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



There is always using substr to mimic the Perl chomp() function.  Look thru
the comments on http://us.php.net/chop and you'll find a few different ways
of doing it.


Or just use trim()  :-)

-Shawn

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] validating textarea using php

2008-05-13 Thread Iv Ray

Sudhakar wrote:
> i do not want
> this to happen, if a user simply hits the spacebar and does not type
> anything i should be able to display an alert message.

From usability point of view such check will, in many cases, generate 
annoyance, and bring nothing.


If I do not want to enter anything, and you "error me" to enter 
"something", I'll do like this -


asdlöfjasdpoöfja spdfj as fsdaölkjf

And your check is dead. If you want "something", you will get "something".

It is hard (from usability point of view) to "validate" textarea to that 
extent, and especially - to get reasonable answers...


I work for a scientific database, where all content providers are very 
intelligent, well educated and very disciplined, and the content editors 
still have hard time thinking how to guide the content provider so that 
they provide reasonable input.


Your problem is not so much php related, but a usability and editorial one.

Iv

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] validating textarea using php

2008-05-13 Thread Robert Cummings

On Tue, 2008-05-13 at 19:02 +0300, Usamah al-Amin wrote:
> >  if(chop($comments) == "") { ... }   //hope that helps.
> 
> Well, chop() is an alias of rtrim(), so it won't work here for, say,
> trimming control characters at the end of the string like line feeds.
> 
> trim() is actually the best bit here.

Actually trim() is probably less efficient since both ends of the string
will be examined whereas a string containing entirely whitespace
characters will rtrim() (chop() if you will) to an empty string also but
the second side won't need to be examined (even if only to check for 0
length).

But maybe you didn't realize this because your assertion was wrong in
the first place:

> so it won't work here for, say, trimming control characters at the
> end of the string like line feeds.

When clearly looking at the online documentation for rtrim() we see:

This function returns a string with whitespace stripped from
the end of str . 

Without the second parameter, rtrim() will strip these characters:

" "(ASCII 32 (0x20)), an ordinary space. 
"\t"   (ASCII  9 (0x09)), a tab. 
"\n"   (ASCII 10 (0x0A)), a new line (line feed). 
"\r"   (ASCII 13 (0x0D)), a carriage return. 
"\0"   (ASCII  0 (0x00)), the NUL-byte. 
"\x0B" (ASCII 11 (0x0B)), a vertical tab.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] validating textarea using php

2008-05-13 Thread Jim Lucas

Richard Heyes wrote:
Also you can use short 
tags (popular...) to make the HTML more readable. Eg:








It also makes the code less portable.

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] validating textarea using php

2008-05-13 Thread Dan Joseph
On Tue, May 13, 2008 at 12:02 PM, Usamah al-Amin <[EMAIL PROTECTED]>
wrote:

> >  if(chop($comments) == "") { ... }   //hope that helps.
>
> Well, chop() is an alias of rtrim(), so it won't work here for, say,
> trimming control characters at the end of the string like line feeds.
>
> trim() is actually the best bit here.
>
> Regards,
> Usamah
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
There is always using substr to mimic the Perl chomp() function.  Look thru
the comments on http://us.php.net/chop and you'll find a few different ways
of doing it.

-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month. Reseller plans and
Dedicated servers available.

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."


Re: [PHP] validating textarea using php

2008-05-13 Thread Usamah al-Amin
>  if(chop($comments) == "") { ... }   //hope that helps.

Well, chop() is an alias of rtrim(), so it won't work here for, say,
trimming control characters at the end of the string like line feeds.

trim() is actually the best bit here.

Regards,
Usamah

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] validating textarea using php

2008-05-13 Thread Hiep Nguyen

On Tue, 13 May 2008, Sudhakar wrote:


hi

i need to validate textarea of a html form using php



presently my php code to validate the text area is

if($comments == "" )
{
$error.="Please enter your comments";
}

with this code if a user hits the space bar once or couple of times as a
matter of fact there are no characters entered by the user i do not want
this to happen, if a user simply hits the spacebar and does not type
anything i should be able to display an alert message.

please advice how i can change the above php code.

thanks.



if(chop($comments) == "") { ... }   //hope that helps.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RES: [PHP] validating textarea using php

2008-05-13 Thread Thiago Pojda
> You really should use htmlspecialchars before showing any user 
> stipulated HTML to help prevent security holes. Also you can use short 
> tags (popular...) to make the HTML more readable. Eg:

> 

Just to add, short tags are not recommended for conflicts with XMLs. Use
 instead.


Atenciosamente,
www.softpartech.com.br
Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
[EMAIL PROTECTED]
Excelência em Softwares Financeiros


-Mensagem original-
De: Richard Heyes [mailto:[EMAIL PROTECTED] 
Enviada em: terça-feira, 13 de maio de 2008 11:45
Para: Sudhakar
Cc: php-general@lists.php.net
Assunto: Re: [PHP] validating textarea using php

> i need to validate textarea of a html form using php
> 
>  echo($comments);?>

You really should use htmlspecialchars before showing any user 
stipulated HTML to help prevent security holes. Also you can use short 
tags (popular...) to make the HTML more readable. Eg:


 


> presently my php code to validate the text area is
> 
> if($comments == "" )

You should not rely on register_globals, and use either $_GET or $_POST 
instead depending on which methoed to send your form details back to the 
server. Eg:

if($_POST['comments'] == '' ) {
 ...
}

> with this code if a user hits the space bar once or couple of times as a
> matter of fact there are no characters entered by the user i do not want
> this to happen, if a user simply hits the spacebar and does not type
> anything i should be able to display an alert message.

You can use the trim() function to determine whether a variable is just 
whitespace.

$comments = trim($_POST['comments']);

if ($comments == '') {
// Show error message
}

-- 
Richard Heyes

++
| Access SSH with a Windows mapped drive |
|http://www.phpguru.org/sftpdrive|
++

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] validating textarea using php

2008-05-13 Thread Warren Vail


> > with this code if a user hits the space bar once or couple 
> of times as 
> > a matter of fact there are no characters entered by the 
> user i do not 
> > want this to happen, if a user simply hits the spacebar and 
> does not 
> > type anything i should be able to display an alert message.

One thing you might consider is, first of all, there are many characters
which do not print and spaces are one of them, but from a computer
standpoint they are characters, tabs and new lines are some others, the list
goes on.

For this specific case you can trim the results and that often will
eliminate most of these if they appear at either end of what was typed, in
this case the entire thing.

If(trim($_POST["textareaname"]) == "") echo "You didn't type anything
significant!";

HTH,

Warren Vail


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] validating textarea using php

2008-05-13 Thread Richard Heyes

i need to validate textarea of a html form using php




You really should use htmlspecialchars before showing any user 
stipulated HTML to help prevent security holes. Also you can use short 
tags (popular...) to make the HTML more readable. Eg:







presently my php code to validate the text area is

if($comments == "" )


You should not rely on register_globals, and use either $_GET or $_POST 
instead depending on which methoed to send your form details back to the 
server. Eg:


if($_POST['comments'] == '' ) {
...
}


with this code if a user hits the space bar once or couple of times as a
matter of fact there are no characters entered by the user i do not want
this to happen, if a user simply hits the spacebar and does not type
anything i should be able to display an alert message.


You can use the trim() function to determine whether a variable is just 
whitespace.


$comments = trim($_POST['comments']);

if ($comments == '') {
// Show error message
}

--
Richard Heyes

++
| Access SSH with a Windows mapped drive |
|http://www.phpguru.org/sftpdrive|
++

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] validating textarea using php

2008-05-13 Thread Thijs Lensselink

Quoting Sudhakar <[EMAIL PROTECTED]>:


hi

i need to validate textarea of a html form using php



presently my php code to validate the text area is

if($comments == "" )
{
$error.="Please enter your comments";
}

with this code if a user hits the space bar once or couple of times as a
matter of fact there are no characters entered by the user i do not want
this to happen, if a user simply hits the spacebar and does not type
anything i should be able to display an alert message.

please advice how i can change the above php code.


PHP is sevrer sided. So if you want to check if a user provided the
textarea with input. You have to submit the page. and let PHP do the magic.
If the textarea is not filled. You could send the user back to the form.
With an apropriat warning message.

It's probably easier to do it with client side javascript.
Check the contents of the textarea on submit and preform some actions  
from there.




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] validating textarea using php

2008-05-13 Thread Sudhakar
hi

i need to validate textarea of a html form using php



presently my php code to validate the text area is

if($comments == "" )
{
$error.="Please enter your comments";
}

with this code if a user hits the space bar once or couple of times as a
matter of fact there are no characters entered by the user i do not want
this to happen, if a user simply hits the spacebar and does not type
anything i should be able to display an alert message.

please advice how i can change the above php code.

thanks.