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

"Click here to verify your email address" link inserts newsletter subscriber once, but emails coupon code over and over

Thread began 5/28/2014 7:40 pm by graham | Last modified 5/30/2014 4:47 pm by Jason Byrnes | 1132 views | 11 replies |

graham

"Click here to verify your email address" link inserts newsletter subscriber once, but emails coupon code over and over

Jason, awhile back, Ray helped me, through a couple of premier support sessions, to double opt-in my newsletter subscribers, while sending out a random generated coupon code when successful. The problem is that when a subscriber clicks the "click here to verify your email address" link they are entered into my database once, but, if they continue to click the original "verify" link, Ray's code keeps sending unique codes ... I want to make sure that if someone clicks it again, they don't get additional codes. I have attached the files that prompt the function ... can you help?

Sign in to reply to this post

Jason ByrnesWebAssist

add an additional if statement around the UE code block:

<?php if($row_reNVerify['emailVerified'] == "0") { ?>
< UE code Block >
<?php } ?>

Sign in to reply to this post

graham

So that the email only sends for a new registrant - perfect. But I think the coding on the newsletter_user_confirm page will still create and insert additional records in my database for each click of the email link sent, even if universal email does not initiate ... how can I tell the page to only insert the registrant, and the accompanying coupon code, once? I still have individual emailid with 4 and 5 codes in my database from multiple clicks of the verification link. Thanks, Jason.

Sign in to reply to this post

Jason ByrnesWebAssist

add the same if statemet around the update record code that adds the additional coupons so it only happens once.

Sign in to reply to this post

graham

I applied your instructions to the UE block, and it worked as desired - no additional emails are sent. However, I have not had any luck in stopping he original verification link from creating additional discount codes. I am not sure whether to add the if statement around the insert record to usercoupons, or one of the update record to newsletter blocks. When the subscriber clicks on the original email verification link, and they have already clicked it once, can I create a show if area on the newsletter_confirm_page that tells them they have already verified the link? What would be the condition to hide the original "Thank you for ..." message? Thanks for any additional help you can give, Jason.

Sign in to reply to this post

Jason ByrnesWebAssist

This is the code that inserts the coupn codes:

<?php
// WA DataAssist Insert
if ("" == "") // Trigger
{
$WA_connection = $mysql_purple;
$WA_table = "usercoupons";
$WA_sessionName = "id";
$WA_redirectURL = "";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_fieldNamesStr = "emailid|couponCode|couponAmount";
$WA_fieldValuesStr = "".$row_reNVerify['emailid'] ."" . $WA_AB_Split . "".$_SESSION['CouponCode'] ."" . $WA_AB_Split . "0.2";
$WA_columnTypesStr = "none,none,NULL|',none,''|none,none,NULL";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode($WA_AB_Split, $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_mysql_purple;
mysql_select_db($WA_connectionDB, $WA_connection);
@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($WA_connection);
if ($WA_redirectURL != "") {
$WA_redirectURL = str_replace("[Insert_ID]",$_SESSION[$WA_sessionName],$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);
}
}
?>


place the if statement around that code.

Sign in to reply to this post

graham

Lightning response ... wow - thank you. I implemented the code and the outcome is almost perfect. No additional UE - no duplicate entries for the same emailID, but the page coding still creates a new random code and replaces it in usercoupons over the one that was originally distributed to the subscriber and, with no UE generated, they will be trying to apply a non-existent one. Best way to not produce the second (or, more) code at all? Again, thanks for the help.

Sign in to reply to this post

Jason ByrnesWebAssist

i see no code on your page that would replace the coupon in the usercoupons table.

i only see code on the page to write the user coupon session:

<p>As a <strong>special thank you for registering</strong>,<br/>here is your <strong>20% Off Coupon Code</strong>:<span style="color:#609
"> <?php echo $_SESSION['CouponCode']; ?></span><br/>The code <strong>may be used only once</strong> and will<br/>
<span style="color:#609
"><strong>deduct 20% from your order total</strong></span>.<br/>


you could add the same if statement around that code to not display the coupon once they have already verified.

Sign in to reply to this post

graham

Even if I blank it out on the page, the $_SESSION["CouponCode"] is still produced at the top on page load, which, at some point, inserts and overwrites any previously entered code in the usercoupons. Is there a condition to be added at the top that prevents $_SESSION["CouponCode"] from setting if the email address is already present?

Sign in to reply to this post

Jason ByrnesWebAssist

move the code to set the session:

<?php
if (!session_id()) session_start();
if("" == "") {
$_SESSION["CouponCode"] = "".WA_RandomPassword(6, false, true, true, "") ."";
}
?>

to be after the code for the recordset, than use the same if state around it to check if email verified in the recordset is equal to 0

Sign in to reply to this post
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...