[PHP] Intelligent Forms and Form Processing

2005-02-15 Thread dan
Hello, all -
I am working on a few small projects to try and teach myself how to 
build intelligent forms.  I have come as far as making a few simple ones 
that are created when their parent function is called.  Something like 
the following:

function displayMyForm($username='',$password='',$account='') {
// do some stuff for the vars that were passed
// create form
}
Nothing much, but it gives me a good footing on the use of displaying 
forms dynamically even when some data is missing - making use of default 
values.

The problem that I am faced with now, as simple as it seems, is a 
situation such as the following:

User goes to index.php, enters in some information.  ACTION='? echo 
$_SERVER['PHP_SELF'] ?' is the action.  Some data is carried in the 
form of variables that were entered in on a form.

I want that same page to catch that data and process it.  If the data 
is complete and valid, pass to another section of the form.  If it is 
not, prompt the user to re-enter some data.

I don't really know what I'm asking here.  I guess ultimately I'm 
curious as to how people make intelligent forms such as this.  How do 
you deal with missing/incomplete values?  What about multiple steps of 
a form?  How do you verify that, if a user is on step 2, they came 
from step 1?  Do you mix $_GET and $_POST to verify the process?

Not coming from a big programming background, some people might think 
that these questions are pretty lame, and I'll go ahead and tell you 
that you are absolutely correct.  However, as I start, I would like to 
develope and work on good programming habits, so I don't learn bad 
habits to begin with.

Any feedback will be appreciated.
Thanks
-dant
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Intelligent Forms and Form Processing

2005-02-15 Thread Matt M.
 Any feedback will be appreciated.


why reinvent the wheel?

take a look at:
http://pear.php.net/package/Html_quickform

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



Re: [PHP] Intelligent Forms and Form Processing

2005-02-15 Thread dan
Matt M. wrote:
Any feedback will be appreciated.

why reinvent the wheel?
take a look at:
http://pear.php.net/package/Html_quickform
To the people who want to truly understand how the system works, the 
wheel, as it stands, is wothless :)

I know I can use a drop-in solution, and I might consider it in the 
future.  However, if I understood in more detail the entire process, I 
would be able to troubleshoot and add advanced features to the wheel.

That's how I look at it, anyway.
Thanks
-dant
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Intelligent Forms and Form Processing

2005-02-15 Thread Bret Hughes
On Tue, 2005-02-15 at 17:00, dan wrote:
 Matt M. wrote:
 Any feedback will be appreciated.
  
  
  
  why reinvent the wheel?
  
  take a look at:
  http://pear.php.net/package/Html_quickform
  
 
 To the people who want to truly understand how the system works, the 
 wheel, as it stands, is wothless :)
 
 I know I can use a drop-in solution, and I might consider it in the 
 future.  However, if I understood in more detail the entire process, I 
 would be able to troubleshoot and add advanced features to the wheel.
 
 That's how I look at it, anyway.
 

I like the attitude from a learning standpoint but since you asked for
feedback you could have at least acknowledged the guys effort in offerin
one solution.

This thread is very similar to another one today.  and the answer is the
same. use some sort of conditional construct to determine how you are
being requested and process accordingly.

I usually set a hidden variable that can be checked to let me know what
to do.

if (isset($_POST[myvar]  $_POST[myvar] = expected value){
 #   perform second phase form
}
else {

#do  form phase one stuff.

print input type=hidden name=myvar value='expected value'\n;

}

one of many ways to do it.  I have to say I have done quite a bit of
this sort of thing and it gets really confusing to maintain if there is
a lot of logic involved.

One one hand it is nice to know you only have to change one file if a
change is needed ( especially if there are changes to the parameters
being passed from the entry side to the processing side.  I have yet to
feel strongly one way or the other whether it is better to use a single
file or multiples.  

Bret

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