This is a discussion on Incomplete form handling within the PHP Language forums, part of the PHP Programming Forums category; What is the best method to handle an incomplete form? How to preserve and display the data that has been ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Animesh K wrote:
> What is the best method to handle an incomplete form? How to preserve > and display the data that has been already filled? > > I know this is classical stuff, but I could not find any great > reference for it yet. > > Best, > Animesh I collect all the POST data into variables. In the HTML area I have the values of the fields set to those variables. I also have the form post to itself and do a header() command to change pages on success. An example might be a text field "city". In the html area I would have <input type="text" name="city" value="<?php echo $city; ?>"> where $city is the value of the obtained from the post of that field. This may not be the best way, but it sure works. Shelly |
|
|||
|
Shelly wrote:
> > I collect all the POST data into variables. In the HTML area I have the > values of the fields set to those variables. I also have the form post to > itself and do a header() command to change pages on success. > > An example might be a text field "city". In the html area I would have > <input type="text" name="city" value="<?php echo $city; ?>"> where $city is > the value of the obtained from the post of that field. > > This may not be the best way, but it sure works. > > Shelly > > Thanks for the quick response. This method should work, as I expected. I was wondering if there is a better method :) Do you post the incomplete data as a hidden post? |
|
|||
|
Animesh K wrote:
> Shelly wrote: > >> >> I collect all the POST data into variables. In the HTML area I have >> the values of the fields set to those variables. I also have the >> form post to itself and do a header() command to change pages on >> success. An example might be a text field "city". In the html area I >> would >> have <input type="text" name="city" value="<?php echo $city; ?>"> where >> $city is the value of the obtained from the post of that field. >> >> This may not be the best way, but it sure works. >> >> Shelly >> >> > > > Thanks for the quick response. This method should work, as I > expected. I was wondering if there is a better method :) > > Do you post the incomplete data as a hidden post? No, I just post it. I then validate it and process it further. Failing validation, it drops through and displays. Successful validation send it off somewhere else when done. -- Shelly |
|
|||
|
On Nov 2, 12:18 am, Animesh K <animesh1...@gmail.com> wrote:
> What is the best method to handle an incomplete form? How to preserve > and display the data that has been already filled? > > I know this is classical stuff, but I could not find any great reference > for it yet. > > Best, > Animesh remember to only echo back to the html filtered input, never do value="<?php echo $input_value; ?>" where $input_value is $_POST['intput_value'] on those required but empty inputs, change their class to cause them to be highlighted and you're on your way. |