View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Check for duplicate email address as well as username (user registration)

Thread began 10/02/2009 4:01 pm by phil | Last modified 1/16/2010 11:30 am by phil | 7694 views | 23 replies

dan361748

Just can't seem to get it to work.

I don't know why, but I just can't seem to get the validation to work. I have 2 validations going on - one to check the email format and the other to check the duplicate status. I've gone through the forums and applied various fixes but the duplicate validation just won't seem to work. Here is my code:

The recordset and the server validation:

<?php
$colname_newsletter = "-1";
if (isset($_POST['fieldset_group_Email_address'])) {
$colname_newsletter = (get_magic_quotes_gpc()) ? $_POST['fieldset_group_Email_address'] : addslashes($_POST['fieldset_group_Email_address']);
}
mysql_select_db($database_ourhands1, $ourhands1);
$query_newsletter = sprintf("SELECT * FROM visitors WHERE VisitorEmail = %s", GetSQLValueString($colname_newsletter, "text"));
$newsletter = mysql_query($query_newsletter, $ourhands1) or die(mysql_error());
$row_newsletter = mysql_fetch_assoc($newsletter);
$totalRows_newsletter = mysql_num_rows($newsletter);

// WA Application Builder Insert
if (isset($_POST["Default_submit"])) // Trigger
{
$WA_connection = $ourhands1;
$WA_table = "visitors";
$WA_sessionName = "VisitorID";
$WA_redirectURL = "index.php";
$WA_keepQueryString = true;
$WA_indexField = "VisitorID";
$WA_fieldNamesStr = "VisitorEmail|userLevel";
$WA_fieldValuesStr = "".((isset($_POST["fieldset_group_Email_address"]))?$_POST["fieldset_group_Email_address"]:"") ."|" . "2";
$WA_columnTypesStr = "',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_ourhands1;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
<?php
if (isset($_POST["Default_submit"])) {
$WAFV_Redirect = "index.php?invalid=true";
$_SESSION['WAVT_index_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateEM((isset($_POST["fieldset_group_Email_address"])?$_POST["fieldset_group_Email_address"]:"") . "",true,1);

if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"index");
}
}
?>
<?php
if (isset($_POST["Default_submit"])) {
$WAFV_Redirect = "index.php?invalid=true";
$_SESSION['WAVT_index_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateNM($totalRows_newsletter . "",-1,0,"",",.",true,3);

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


My 2 form fields:
<div class="fieldGroup"> <span id="fieldset_group_Email_address_Spry">
<input id="fieldset_group_Email_address" name="fieldset_group_Email_address" type="text" value="<?php echo((isset($_GET["invalid"])?ValidatedField("index","fieldset_group_Email_address"):"")); ?>" class="formTextfield_Large" tabindex="1" onblur="hideServerError('fieldset_group_Email_address_ServerError');"/>
<span class="textfieldInvalidFormatMsg">Invalid format.</span><span class="textfieldRequiredMsg">Please enter your email address.</span> </span>
<?php
if (ValidatedField('index','index')) {
if ((strpos((",".ValidatedField("index","index").","), "," . "1" . ",") !== false || "1" == "")) {
if (!(false)) {
?>
<span class="serverInvalidState" id="fieldset_group_Email_address_ServerError">Please enter an email address.</span>
<?php //WAFV_Conditional index.php index(1:)
}
}
}?>
<?php
if (ValidatedField('index','index')) {
if ((strpos((",".ValidatedField("index","index").","), "," . "2" . ",") !== false || "2" == "")) {
if (!(false)) {
?>
<span class="serverInvalidState" id="fieldset_group_Email_address_ServerError">That address is already in our databse.</span>
<?php //WAFV_Conditional index.php index(2:)
}
}
}?>
</div>

Any help would be really appreciated.

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