[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
Re: [ic] Ok so Im an idiot, but its still broken...[error ] tag
The "problems" with this page have been around since the mv4 days. I ran into
the same thing a year or so ago. There are actually a two problems here
(this all refers to mv4, as I haven't looked at what IC does differently).
1. profiles placed in "order.profiles", or "profiles.order", or even
in-line in a mv_check block are only validated during the order
routing process which happens when a person places an order.
This includes handy things like email address validation.
2. the userdb login code will check for, and report, certain types
of errors - mismatched password, duplicate userid, etc. - but will
not report empty fields that you may have designated as required.
My solution that I've reused a couple of times now is to create a mv_click
block (or even just an inline [perl] or [mvasp] block) that checks for
required fields and validates the email address. Here's an example that
adds to/replaces the "NewAccount" mv_click in new_account.html:
[set NewAccount]
[set loginfail][/set]
[tag flag write]userdb[/tag]
[perl global=1]
# copy form vars from cgi to values, as [userdb new_account] requires
# that most of its vars be passed as values, rather than cgi vars.
::update_values();
# check for empty fields
my @required_fields = (qw/
fname lname address1 city
state zip email phone_day
/);
for (@required_fields) {
if (! $Values->{$_}) {
$Vend::Session->{failure} =
$Vend::Session->{errors}{$_} = "Required field $_ is empty.";
$Scratch->{loginfail} = 1;
}
}
# attempt to validate the email address if no previous failures
if (! $Scratch->{loginfail} && $Values->{email} !~
/[\040-\176]+\@[-A-Za-z0-9.]+\.[A-Za-z]+/) {
$Vend::Session->{errors}{email} =
$Vend::Session->{failure} = "Badly formatted email address";
$Scratch->{loginfail} = 1;
}
[/perl]
mv_nextpage=new_account
[if scratch loginfail]
[log]new account not created[/log]
[else]
[if type=explicit compare="[userdb function=new_account log=1]"]
[log]new_account create ok![/log]
mv_nextpage=account
[tag export userdb][/tag]
[else]
[log]new_account create failed![/log]
[log interpolate=1][data session failure][/log]
[/else]
[/if]
[/else]
[/if]
[/set]
<P>
[if type=explicit compare="[error all=1 show_var=1 keep=1]"]
<FONT COLOR=RED>One field was either empty, or contained wrong data.</FONT>
The fields are marked with <FONT COLOR=RED>this color</FONT>.
<P>
[/if]
[if session failure]
The error was:
<FONT COLOR=red>[loc][perl]$Vend::Session->{failure}=~s/\s+$//;
return $Vend::Session->{failure};[/perl][/loc]</FONT>
[data base=session field=failure value=""]
[/if]
<P>
-Bill
"Cameron B. Prince" wrote:
>
> Originally, the construct demo was setup to only check for errors on the
> checkout page.
>
> It seems there is a bug in the error checking code addition to the account
> page.
>
> I'll look into this,
>
> Thanks,
>
> Cameron
>
> -----Original Message-----
> From: interchange-users-admin@minivend.com
> [mailto:interchange-users-admin@minivend.com]On Behalf Of Strider
> Centaur
> Sent: Monday, October 16, 2000 10:46 AM
> To: interchange-users@minivend.com
> Subject: Re: [ic] Ok so Im an idiot, but its still broken...[error ] tag
>
> But the if statement is already in the account form. It all seems to be
> in
> there, here's the test they have:
>
> FROM VIRGIN ACCOUNT.HTML
>
> [if type=explicit compare="[error all=1 show_var=1 keep=1]"]
> <P>
> <font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>There were
> errors in your last submission.</b>
> <br>
> They are shown in <FONT COLOR=__CONTRAST__>__CONTRAST__</FONT> below.</FONT>
> <P>
> [/if]
>
> That implies to me that the page should be checking for all required
> fields
> when the submit button is pressed. This simply is not what is happening.
>
> I don't think the intent was to wait till a user checked out to check
> the
> information they entered in the Customer Service area. That would simply be
> wrong. :-)
>
> "Cameron B. Prince" wrote:
>
> > I think the idea here was to do all the error checking on the checkout
> page.
> >
> > You should be able to take the code from checkout and use on account if
> > you'd like to check it there too.
> >
> > Good luck,
> >
> > Cameron
> >
> > -----Original Message-----
> > From: interchange-users-admin@minivend.com
> > [mailto:interchange-users-admin@minivend.com]On Behalf Of
> > jojo@buchonline.net
> > Sent: Monday, October 16, 2000 5:12 AM
> > To: interchange-users@minivend.com
> > Subject: Re: [ic] Ok so Im an idiot, but its still broken...[error ] tag
> >
> > On 16 Oct, Strider Centaur wrote:
> > > Hans, thanks but that is the same as the example, and like the
> > example
> > > it did nothing. I guess my question is more specific to a certain page
> > > than to the general use of [error]. The page in question is the
> > > account.html page provided with the construct demo site. The problem is
> > the
> > > error tests on that page specifically do not work. Both here locally
> and
> > on
> > > the online demo at Akopia. I have been over the code of that page
> several
> > > times and it all looks good, but yet something is hosing it.
> > >
> > > It would be my guess that others have had the same problem and I
> would
> > > imagine the guys at akopia would have some interest it resolving it,
> less
> > > someone get the idea that interchange is buggy. :-)
> >
> > I can confirm this! I've look the construct account page and did not get
> > any feedback too.
> >
> > Joachim
> >
> > BTW:
> > Why did I see
> >
> > [comment]
> > <!-- Account change profile in etc/order.profiles -->
> > [/comment]
> >
> > and
> >
> > server:[jojo]# ls -al order.profiles
> > ls: order.profiles: No such file or directory
> >
> > server:[jojo]# ls -al profiles.order
> > -rw-r--r-- 1 jojo jojo 3198 25 Sep 11:30 profiles.order
> >
> > ?
> >
> > --
> > Hans-Joachim Leidinger
> > buch online jojo@buchonline.net
> > Munscheidstr. 14 FAX: +49 209 1671441
> > 45886 Gelsenkirchen FAX: 0209 1671441
> >
> > _______________________________________________
> > Interchange-users mailing list
> > Interchange-users@www.minivend.com
> > http://www.minivend.com/mailman/listinfo/interchange-users
> >
> > _______________________________________________
> > Interchange-users mailing list
> > Interchange-users@www.minivend.com
> > http://www.minivend.com/mailman/listinfo/interchange-users
>
> --
> Strider Centaur
> HTTP://www.Scifi-Fantasy.com
>
> " It is my observation that unless you really understand the issues, you
> are
> hardly in a position to criticize. Nearly all Linux users have used
> Windows,
> but very few Windows users have used Linux. " -- Me
>
> _______________________________________________
> Interchange-users mailing list
> Interchange-users@www.minivend.com
> http://www.minivend.com/mailman/listinfo/interchange-users
>
> _______________________________________________
> Interchange-users mailing list
> Interchange-users@www.minivend.com
> http://www.minivend.com/mailman/listinfo/interchange-users
_______________________________________________
Interchange-users mailing list
Interchange-users@www.minivend.com
http://www.minivend.com/mailman/listinfo/interchange-users