Reply to RE: [PHP] Creating intelligent forms

Your name:

Reply:


Posted by Mike on 10/21/25 11:13

> The first idea I had was to make a function to display the
> form. When the form is submitted, the page would be called
> again (i.e. the form's ACTION=itself), and then the POST or
> GET or SESSION variables will be the arguments to the form.
> The idea is, when this happens, the form will be able to
> check the data that was sent, verify it, etc etc. If there
> are no problems with the data, then the user is directed to
> step 2 of the form, or the second page, to enter in
> additional data. But how should the redirection happen?
>
> At that point, am I able to manipulate the headers for a
> different Location:, that location being the second form to
> be filled out? Since this would be the first data sent to
> the BROWSER, I thought that this might work.

What I've done is just have one script (call it form.php) and when you
process the data it posts/gets to itself. The first thing you do is validate
the data. You then flag each piece that has a problem. If you have no
problems after you've parsed all the data, you can simply include the
"processing" code from another file and then run that (no redirection) and
output what you need to output. If there are problems, just re-run the
print-form portion of the script but output the fields with the
previously-submitted data and also some sort of visual marker for the user
to identify that there's a problem (such as red text saying "Please correct
this field" or something).

> I've been toying with both of these ideas with varying
> success, but haven't quite gotten it figured out. I'm sure
> that, with due time, I'll be able to figure it out. However,
> I just want to make sure that this is a "correct" way of
> writing forms, and if it's normally accepted as a common
> practice, so I don't waste my time doing something that might
> not actually work.

I've done the above with much success. And I prefer not to have to redirect
people all over the place if possible. There's truly many ways of doing it
and different ways may work best for your needs - but I wanted to share what
has worked for me in the past.

-M

[Back to original 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

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