[ic] account.html : How to Save only if No Errors?

interchange-users@icdevgroup.org interchange-users@icdevgroup.org
Sun Jun 30 02:33:03 2002


In my account.html , is there a way I can Save into database ONLY if 
there're no errors on the form (ie, all required fields are filled 
in)?

I tried to test for that condition using "if errors", but it doesn't 
seem to work.  "if errors" worked if I use it under [seti 
Save_database] (ie, intepolate), but that is not what I want.  I only 
want the program to call Save_database only upon clicking of the 
Submit button (ie, [set Save_database]), not upon loading of the page.

Any ideas how I could achieve this?  TIA for any advice!


Btw, I'm calling "my_account_profile" using mv_order_profile, and 
"Save_database" using mv_check.  Upon clicking of Submit, which will 
be done first?  I think should be my_account_profile , is that right 
(hopefully so!)?  I need my_account_profile to be called first so 
that I can make use of the Error results in Save_database to 
facilitate checking if all required fields are filled in first, 
before saving into database.


Below is part of the codes which I think might be useful to aid 
understanding of what I'm doing now...

-------------------------------------------------------------------------------------------

[set my_account_profile]
fname=required
lname=required

&fatal = yes
[/set]





[set Save_database]

  [if errors]
  [then]
  [/then]
  [else]

...blah blah...

  [userdb save]

  [/else]
  [/if]
[/set]





[if type=explicit compare="[error all=1 show_var=1 keep=1]"]
    <P>
    <FONT COLOR=RED>There were errors in your form 
submission.</FONT><br>
    The fields are marked with <FONT COLOR=RED>this color</FONT>.
    <P>
    <P>
    The error was:<br>
    <BLOCKQUOTE>
        [error all=1 show_error=1 show_label=1 joiner="<BR>" keep=1]
    </BLOCKQUOTE>
[/if]




<INPUT TYPE=hidden NAME=mv_session_id VALUE="[data session id]">
<INPUT TYPE=hidden NAME=mv_order_profile VALUE=my_account_profile>
<INPUT TYPE=HIDDEN NAME=mv_check    VALUE="Save_database">
<INPUT TYPE=hidden NAME=mv_todo     VALUE=submit>
<input type=hidden name=mv_successpage value="home">
<input type=hidden name=mv_failpage value="account">


...blah blah (form fields) ...

<INPUT TYPE=SUBMIT VALUE="Save Changes">