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

Posted by Jerim79 on 11/10/06 22:13

Jerim79 wrote:
> 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
> 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. 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.

I am just starting work on editing a PHP script that someone else in
the company wrote. I noticed that this person chose to use different
PHP pages depending on the error. For instance, the main form contains
input boxes for Name, Address, Telephone and Email. When submitted, the
form calls a file called verify_email.php. This file runs an if/then
statement. If the email is valid it calls another form, such as
verify_name and so on until everything is validated and the information
is written to the database. If the email is invalid, it displays a new
form which is similar to the original form, only this one has the email
box highlighted in red and asks the user to enter the email again. All
the input boxes are already filled in as the coder chose to use PHP
variables to re-enter the information for the customer, instead of
having to start over.

The question I have is, is this an "acceptable" way to handle error
messages. Being quite new to PHP I don't know what to make of this
method.

 

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

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