close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Limit coupon use to three times?

Thread began 10/15/2009 9:00 am by bec341098 | Last modified 12/31/2009 11:51 am by bec341098 | 4966 views | 18 replies

jstoler155201

Here's another twist to produce a descending #

Hey b,

Here is another way to do it.

In your DB make the default value for the coup_use table 3. We'll just count backwards.

Then use the Dreamweaver built-in update behavior to update the coupon. The behavior will be created in a Wizard and placed on your page at the right place, most likely. I would need to see the all the page code to be sure.

You will then want to use the Submit Button for that update to be the button the user pushes to validate their coupon.

Here is the update code you need - it goes near the top, but under $theValue switch()'s code generated by Dreamweaver, also under the start_session() stuff:
<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE visitors SET coup_use=-1 WHERE VisitorID=%s",
GetSQLValueString($_POST['coup_use'], "int"),
GetSQLValueString($_POST['VisitorID'], "int"));

mysql_select_db($database_db_name, $db_name);//Make sure you change both to your DB
$Result1 = mysql_query($updateSQL, $db_name) or die(mysql_error());//Make sure you change the $db_name to your DB

$updateGoTo = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
?>

Then under the DOC Type in the <body> is the coupon form:

<form name="form1" action="<?php $_SERVER['PHP_SELF'];?>" method="post">
<input name="coup_use" type="text" value="<?php echo htmlentities($row_rsCoupUpdate['coup_use'], ENT_COMPAT, 'UTF-8'); ?>" size="5" readonly="readonly" /><br />
<input type="submit" value="Use a Coupon" />
<input type="hidden" name="VisitorID" value="<?php echo $row_rsCoupUpdate['VisitorID']; ?>" />
<input type="hidden" name="MM_update" value="form1" />
</form>

At that point you would have a conditional if/else statement that if the # was =<0 a message (in place of the form) would say All Coupons Used or something.

Make sure you change the DB name in the code and set your DB coup_use default value to 3.

This (minus style) should work as written. Let me know.

Best,
Jay

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