close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Trying to Avoid duplicate entries

Thread began 5/09/2009 9:46 pm by mustang_sally_85344510 | Last modified 5/12/2009 10:43 am by Ray Borduin | 6032 views | 15 replies |

mustang_sally_85344510

Trying to Avoid duplicate entries

Hello,
I was wondering how to avoid a dupicate entry into a DB.? For example, I have a table that I want a user to only be able to enter data into ONCE.
Which WA extention would be best for this. I have WA Supersuite.
I would like to check/validate the database by visitorID.

Thank you in advance for steering me in the right direction! :)

Sign in to reply to this post

Ian

Is VisitorID the unique ID for the table? If so, it should be set to auto increment anyway.

However, if Visitor ID is another field in the table then the best way to do this is call a recordset on "Post" of the form against the values in the form, check to see if the recordset is populated. If it is then present an error and if it isnt then use Data Assist to insert the record.

I might be wrong but I dont think Data Assist will do all this for you - you need to do a bit of manual coding to acheive the result.

Cheers
Ian

Sign in to reply to this post

mustang_sally_85344510

visitorID is NOT the unique ID in this particular table. Is is NOT the autoincrement field. I don't remember DATAASSIST asking for compare to variables....I do however recall SecurityAssist asking for what compare to variables...? Thank you for your input, and I'll give it a try! :)

Sign in to reply to this post

Ray BorduinWebAssist

I would create a recordset filtered by the id and use validation toolkit to validate that no records are returned from that recordset.

Sign in to reply to this post
Did this help? Tips are appreciated...

mustang_sally_85344510

when if filter the recordset...specifically...could you please give me the exact language to filter? My insert record has the "hidden" value for the visitorID, which is carried by the loginvisitorID,...so do I used the visitorID session variable, entered value or what? I do appreciate your help! :)

Sign in to reply to this post

Ray BorduinWebAssist

Filter using the simple recordset wizard. Filter from the submitted form element based on the field that you want to ensure is unique.

The first step is to create the recordset that shoudl return no results if there are no repeats and one result if there are repeats.

Sign in to reply to this post
Did this help? Tips are appreciated...

mustang_sally_85344510

Was wondering...
Does it make any difference if I have "Security Assist Access to page" applied to the same page? as, I do...

Sign in to reply to this post

Ray BorduinWebAssist

It shouldn't but I guess it depends on your workflow and settings. It won't interfere directly, but it could cause an unrelated problem that could be confusing.

Maybe remove the restrict access server behavior if you think it might be causing issues and add it back once everything else is working.

Sign in to reply to this post
Did this help? Tips are appreciated...

mustang_sally_85344510

Hi again,
I removed page access...At this point nothing can be entered.
Here is VALADATION code.
<?php
if (isset($_POST["submitcenter"])) {
$WAFV_Redirect = "alreadyentered.php";
$_SESSION['WAVT_centerinput_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateNM($row_rsverify['VisitorID'] . "",0,0,"",",.",true,1);

if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"centerinput");
}
}
?>

Here is recordset code:
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$colname_rsverify = "-1";
if (isset($_POST[''])) {
$colname_rsverify = (get_magic_quotes_gpc()) ? $_POST[''] : addslashes($_POST['']);
}
mysql_select_db($database_bowlingtournaments, $bowlingtournaments);
$query_rsverify = sprintf("SELECT VisitorID FROM centers WHERE VisitorID = %s", GetSQLValueString($colname_rsverify, "text"));
$rsverify = mysql_query($query_rsverify, $bowlingtournaments) or die(mysql_error());
$row_rsverify = mysql_fetch_assoc($rsverify);
$totalRows_rsverify = mysql_num_rows($rsverify);
?>

Sign in to reply to this post

Ray BorduinWebAssist

Make sure to move the recordset code above the validation code, and the line:

$WAFV_Errors .= WAValidateNM($row_rsverify['VisitorID'] . "",0,0,"",",.",true,1);

should be:

$WAFV_Errors .= WAValidateNM($totalRows_rsverify . "",0,0,"",",.",true,1);

Sign in to reply to this post
Did this help? Tips are appreciated...
loading

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...