Akopia Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

[mv] dup checking when writing to database



Title: dup checking when writing to database

Hi list,


Can anyone provide examples of duplication checking before adding values to a database?


I have created a newsletter database for a Minivend site and I am using the following code to add addresses to it. This code works well, but I would like to add a function that would produce an error if an address is already in the database.

With the schema I have now (2 Columns: Address and Active) it’s not possible to add a duplicate, but no error is produced.

Any ideas?


Thanks,

Cameron





SUBSCRIBER FORM:

[set check_form]

[if value email eq your@email.com]

[or !value email]

[then]

form_errors=Please enter your own valid email address.

mv_nextpage=subscribe-error

[/then]

[else]

tracking_number=[counter etc/newsletter.counter]

mv_nextpage=subscribe

[/else]

[/if]

[/set]

       

[set email_active]1[/set]

               

<FORM ACTION="[process-target]" METHOD=POST>

<INPUT TYPE=hidden NAME=mv_todo VALUE=return>

<INPUT TYPE=hidden NAME=mv_check VALUE=check_form>

<input TYPE="text" NAME="email" SIZE="17" value="your@email.com">

<input type="image" src=""button-go.gif"" border=0></td>

</form>



SUBSCRIBE PAGE:

[if !scratch email_active]

You have previously subscribed, or you are accessing this page without using the subscriber form.

[else]

[set email_active][/set]

[set name=email_sent interpolate=1]

[perl arg=sub interpolate=1]

        form_mail

                (

                        q{[value email]},

                        q{Newsletter Subscription},

                        q{info@somedomain.com},

                        <<'EOMail' )

Dear visitor,

You have been successfully subscribed to the newsletter.

EOMail

[/perl]

[perl arg=sub interpolate=1]

        form_mail

                (

                        q{__ORDERS_TO__},

                        q{New Newsletter Subscriber},

                        q{[value email]},

                        <<'EOMail' )

Email address [value email] has been added to the newsletter subscribers database.

EOMail

[/perl]

[/set]

[if scratch email_sent]

Your email address: [value email] has been successfully added to our newsletter subscribers.

[seti newsletter]

[tag flag write]newsletter[/tag]

[try]

[import table=newsletter type=LINE continue=NOTES]

subscribers: [value email]

active: 1

[/import]

[/try]

[catch] There was an error adding the subscriber. [/catch]

[/seti]

       

[else]

An error has occurred while attempting to add your email address to our newsletter subscribers.

[/else]

[/if]

[/else]

[/if]


Search for: Match: Format: Sort by: