Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Duplicate ebtries

LEGEND ,
Feb 04, 2007 Feb 04, 2007

Copy link to clipboard

Copied

Hi guys,

I want to stop duplicate entries into a mysql database. But, I only want to
stop the entry if TWO of the fields are a duplication.

eg i dont want to allow a name and email address to be the same as already
entered. But, either the name or email address can be the same.

Can anyone help please?

Thanks


TOPICS
Server side applications

Views

278
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 04, 2007 Feb 04, 2007

Copy link to clipboard

Copied

ghoti1 wrote:
> I want to stop duplicate entries into a mysql database. But, I only want to
> stop the entry if TWO of the fields are a duplication.
>
> eg i dont want to allow a name and email address to be the same as already
> entered. But, either the name or email address can be the same.

This is quite easy, but involves moving a little code around in Code view.

In your insert page, create a recordset to query the database. Use the
Advanced recordset dialog box to create a SQL query like this:

SELECT * FROM myTable
WHERE name = var1
AND email = var2

Click the plus button in the Variables field to create the variables
var1 and var2. Set the runtime value of the first to $_POST['name'] and
the second one to $_POST['email'] (amend the names to match the names
you have given the name and email fields in the insert form). Click OK
to close the Recordset dialog box.

Dreamweaver always creates the recordset code immediately above the
DOCTYPE. You need to move all of the recordset code above the code that
inserts the record in the database. Then wrap the insert record code in
a conditional statement like this:

if ($totalRows_recordsetName == 0) {
// insert code goes here
}
else {
// code to alert user that the action has been cancelled
}

If you have a reasonable amount of experience with PHP, it's quite
simple to do. If you rely on Dreamweaver to handle all the code, you
might struggle a bit.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 05, 2007 Feb 05, 2007

Copy link to clipboard

Copied

LATEST
erm...ok, I'm gonna struggle a bit!!

But hey thanks for the help, I will master it somehow!!!!


"David Powers" <david@example.com> wrote in message
news:eq4us7$o46$1@forums.macromedia.com...
> ghoti1 wrote:
>> I want to stop duplicate entries into a mysql database. But, I only want
>> to stop the entry if TWO of the fields are a duplication.
>>
>> eg i dont want to allow a name and email address to be the same as
>> already entered. But, either the name or email address can be the same.
>
> This is quite easy, but involves moving a little code around in Code view.
>
> In your insert page, create a recordset to query the database. Use the
> Advanced recordset dialog box to create a SQL query like this:
>
> SELECT * FROM myTable
> WHERE name = var1
> AND email = var2
>
> Click the plus button in the Variables field to create the variables var1
> and var2. Set the runtime value of the first to $_POST['name'] and the
> second one to $_POST['email'] (amend the names to match the names you have
> given the name and email fields in the insert form). Click OK to close the
> Recordset dialog box.
>
> Dreamweaver always creates the recordset code immediately above the
> DOCTYPE. You need to move all of the recordset code above the code that
> inserts the record in the database. Then wrap the insert record code in a
> conditional statement like this:
>
> if ($totalRows_recordsetName == 0) {
> // insert code goes here
> }
> else {
> // code to alert user that the action has been cancelled
> }
>
> If you have a reasonable amount of experience with PHP, it's quite simple
> to do. If you rely on Dreamweaver to handle all the code, you might
> struggle a bit.
>
> --
> David Powers, Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> Author, "PHP Solutions" (friends of ED)
> http://foundationphp.com/


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines