You are here: Re: Form validation « PHP Programming Language « IT news, forums, messages
Re: Form validation

Posted by Gordon Burditt on 11/10/06 21:28

>I am looking into form validation for my HTML form. I don't want to use
>javascript and was looking into using PHP. A crazy thought crossed my
>mind and I just wanted to get some input.

>What if I basically made the form one long if/then statement? I could

HTML does not have if/then statements.

PHP runs server-side. It doesn't run until the user fills out the
whole form. If you want to ask for each individual item one at
a time, that's OK, but pretty darned annoying, and a lot of users
are going to give up.

JavaScript is often Turned Off (tm).

>ask for the first piece of information, test it against some
>conditions, then if it is okay I allow the user to fill in the next
>piece of information. I could go do down the page validation each box
>as we go. I could use hidden on all the text boxes until the previous
>condition had been validated.

Why? To annoy users and make them go away?

Note that you *MUST* validate any security-related restrictions on
the server side *ANYWAY* because spambots and thieves will probably
have Javascript turned off and bypass validation to steal stuff or
send SPAM through your server.

>Some pseudocode:
>
><?php
><form action=POST method=registered.php>
><input name"Fname" type="text">
>if ($Fname meets some condition)
> {
> <input name="Lname" type="text">
> if ($Lname meets some condition)
> {
> <input name="Number" type="text>
> if ($Number meets some condition)
> {
> }
> }
>}
>else;
> echo "Please enter a phone number";
>else;
> echo "Please enter a valid last name";
>else;
> echo "Please enter a valid first name";
>?>
>
>I know the code isn't exact, I am just theorizing here. Could such a
>thing be done? Even remotely similar? I don't really plan on doing this
>anytime soon, but I was just curious. I only started PHP programming a
>few days ago so no need to point out how stupid this may sound.
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация