close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Unique database value

Thread began 2/22/2014 3:37 am by CraigR | Last modified 2/27/2014 11:36 am by Jason Byrnes | 246 views | 3 replies |

CraigRBeta Tester

Unique database value

I have a registration form on which I am validating for unique database value on username and email address(es)

Everything seems to work ok, unless i leave the email address field empty, in which case the validation indicates I have a duplicate value, (there are no empty strings in the table field)

If there was only one email address field, this would be no problem, as email address 1 is a required field, but email address 2 and 3 are not required, and i want to check for duplicate value on these as well.

Also, grateful if someone could explain the function of the 'Key Value' option, when setting the Unique database value in the server validation server behavior.
All posts seem to indicate it should be set to 0, but if this is always the case it would be pointless in having it.

Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

The Unique Database value wont take an empty string.


to work around this, you can force a string if the post is empty.

when you add the unique DB validation and the select the Server variable, the server variable code will look like:
((isset($_POST["elementName"]))?$_POST["elementName"]:"")

edit that to:
((isset($_POST["elementName"]) && $_POST['elementName'] != "")?$_POST["elementName"]:"NA")


this will check for an empty value and force it to look for "NA" is empty.

the key value option is used in an update scenario.

If the user is logged in, and updating their information, they should still be able to use their existing email address.

in this case, the key value should be set to use the ID session created by the login page. that will look up the record for the logged in user and allow the email address for that record to pass validation, but not any other email address in the database.

in other words, it is used to lookup the exception to the rule.

Sign in to reply to this post

CraigRBeta Tester

The code to force a string if the post is empty works great, so my registration page is now working properly.

On my update page, I used the url variable for the userid as the key value. Seems to be working.

Thanks Jason

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...