[FX.php List] Form Redux Basics
Erik Andreas Cayré
erik at cayre.dk
Sat May 19 05:11:55 MDT 2007
Den 18/05/2007 kl. 19.18 skrev Jonathan Schwartz:
> Hi folks,
>
> Just when you think that you know what you are doing, you find
> yourself back at square one.
>
> I'm working on a "update your information" page. The form
> containing basic input fields that are initially populated from
> Filemaker. The submit button points php back to the same page
> ['PHP_SELF'], where the top half of the page/script deals with
> error checking. If there are no errors, the page heads off to the
> next page. If there are errors, the page redisplays the form plus
> the error message. The top half of the page containing error
> checking is only processed if the submit button has been clicked.
I use a similar strategy on several pages...
> Here's the issue. The first time the form is displayed, it
> displays data from the FMP query. However, the second time it
> displays would be if an error was found. It should display the data
> that has been submitted in the form that has not yet been sent to
> FMP for updating the file.
>
> Thus, the form needs to display data from two different states:
> Initial FMP query values or updated values entered in this session.
At the start:
if (isset($_POST['submit'])) // user has posted the form
{
// stuff the POST data into $_SESSION
// error checking
} else // no post data, fetch from DB
{
// FX code
// stuff into $_SESSION
}
Then:
if ($error == FALSE)
{
// Great! Redirect to next script/page
} else
{
// Not done yet. Display form with fields containing $_SESSION (and
possibly error messages)
}
> Here's what I did. Upon the initial FMP query, I write the field
> values to $_SESSION variables. The form displays the SESSION
> variables. Also ,when the form is submitted and runs the error
> checking at the top of the page, I set the SESSION variables again
> from the $_POST. Finally, the FMP query to update the file would
> be based on SESSION variables.
>
> I suppose that I could use a different method that contains a php
> if statement at each field, determining which values gets
> displayed, FMP query or $_POST, but that seemed tedious.
>
> Anyone else have the same experience?
>
> Thx
>
> Jonathan
>
> --
> Jonathan Schwartz
> Exit 445 Group
> jonathan at exit445.com
> http://www.exit445.com
> 415-381-1852
> FileMaker 8 Certified Developer
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
---
Erik Andreas Cayré
Spangsbjerg Møllevej 169
6705 Esbjerg Ø
Privat Tel: 75150512
Mobil: 40161183
---
»Interesse kan skabe læring på en skala sammenlignet med frygt, som
en nuklear eksplosion i forhold til en kineser.«
--Stanley Kubrick
»Kun p....sure mennesker kan ændre verden. Innovation skabes ikke af
'markedsanalyse', men af folk, der er afsindigt irriterede over
tingenes tilstand «
--Tom Peters
»Hvis du ikke kan forklare det simpelt, forstår du det ikke godt nok.«
-- Albert Einstein
»Hvis du ikke har tid til at gøre det rigtigt, hvornår vil du så have
tid til at lave det om?«
-- John Wooden, basketball coach
More information about the FX.php_List
mailing list