RE: [PHP] Form validation: client- or server-side?
| From: | craig | Date: | Fri, 09 Jan 2004 18:19:55 +0000 |
| Subject: | RE: [PHP] Form validation: client- or server-side? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-174157@lists.php.net to get a copy of this message | ||
> Is there a distinct advantage to doing form validation /
> error checking on
> the server side using PHP?
The actual code you use to validate remains hidden from a potential
malicious user, while javascript code can be seen, so if there is a
hole in your error checking, it can be found easier.
The big advantage to javascript is that it is fast, since a request
isn't sent back to the server, processed, and then sent back. It also
reduces network traffic, and reduces server load.
> That's how I've always done it
> because I know
> PHP better than JavaScript, but wouldn't it make sense to
> validate as much
> of your form as possible using JavaScript before the form was
> ever posted?
> I'm just talking about the basics, like empty required fields, illegal
> characters, string lengths, etc.
even if you partially validate on the client, you still have to validate
on the client side, which seems redundant to me.
>
> What are your preferred methods? I do an awful lot of
> content management
> with HTML forms, so it's not an entirely spurious question.
I only use javascript for things that I can't do with php, and I can
validate with php.
that's my 2 cents worth,
Craig
>
> --
> Matt Grimm
> Web Developer
> The Health TV Channel, Inc.
> (a non - profit organization)
> 3820 Lake Otis Parkway
> Anchorage, AK 99508
> 907.770.6200 ext. 686
> 907.336.6205 (fax)
> E-mail: mgrimm@healthtvchannel.org
> Web: www.healthtvchannel.org
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>