Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to build an "Enter Contest to Win Prizes" Application

Posted on 2004-08-24
8
Medium Priority
?
348 Views
Last Modified: 2013-12-24
I am a basic Coldfusion developer with not a lot of advanced skills. I have a website where i want users to be able to enter into a monthly drawing to win prizes. The prizes will be mailed to the winner so I will need the users contact information. The main reason i want to do this is i want people to come back regularly. my site changes everyday and new things are posted that i want users to see. Hopefully once it gets started, i will have weekly contests. Does anyone have an idea of how this can be done? and can you instruct me on how to implement the application? Once the drawing is made, i would like to have all the users that entered but did not win receive an email stating that they did not win but to try again. I am using an Access database. Thanks for you help!

IShiva
0
Comment
Question by:IShiva
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 35

Expert Comment

by:mrichmon
ID: 11882527
Well you need an "entry page"

That is a simple form asking for the data you need (name, email, and whatever else such as phone, actual address, etc)


That saves to a table in the dataabase, be sure to store an autonumber ID for each entry.


Then you have a page that only you use to select the winner.  When you click the button a random number between the first entry and the last entry number from the timeperiod.  I think the random function in access in Rnd(), but you may need to double check that.

You contact that person that they are the winner and maybe move the record to a winner table with a datestamp.

Then you send an email to all of the rest of the people in the entry table and delete all records in the entry table.

You are now ready to start a new contest.


SO it is really 2 pages.

Hope taht helps get you started.  As you start coding you can post new questions if you run into problems, but there is not much more we can do for you until you at least start coding yourself.
0
 

Author Comment

by:IShiva
ID: 11882609
ok, i think i get it, ill start to code and see what i can come up with. As for the sending email, im a little confused  on how to code that page where it will select a random entry. any more insight regarding that page for me?

Thanks mrichmon!

IShiva
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 11883029
Well you have it pull a random ID from the database of entires using the random function.

A quick search on Google shows that for access it is Rnd as I guessed.  Here is a good page that shows example usage:

http://www.techonthenet.com/access/functions/numeric/rnd.htm

Or you could generate the random number in cold fusion

SO you could do something like

<cfquery datasource="mydsn" name="upperbound">
SELECT MAX(ID) AS ID FROM entrytable
</cfquery>

<cfquery datasource="mydsn" name="lowerbound">
SELECT MIN(ID) AS ID FROM entrytable
</cfquery>

<cfset WInnerID = RandRange(#lowerbound.ID#, #upperbound.ID#)

<!--- get winner info --->
<cfquery datasource="mydsn" name="getwinner">
SELECT * FROM entrytable
WHERE ID = #WinnerID#
</cfquery>

<!--- move winner info to winner table --->
<cfquery datasource="mydsn">
INSERT INTO winnertable
SELECT * FROM entrytable
WHERE ID = #WinnerID#
</cfquery>
0
Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

 
LVL 35

Accepted Solution

by:
mrichmon earned 500 total points
ID: 11884172
I had to leave, but here is more of the code contrnuing from above


<!--- Delete winner from entry table --->
<cfquery datasource="mydsn">
DELETE FROM entrytable
WHERE ID = #WinnerID#
</cfquery>

<!--- select all entries to email "try again" --->
<cfquery datasource="mydsn" name="getlosers">
SELECT * FROM entrytable
</cfquery>

<cfloop query="getlosers">
<cfmail to="#email# from="youremail@yourdomain.com" subject="Try Again" type="html">
I am sorry but you did not win.

This month's winner was #getwinner.FirstName# #getwinner.lastname#.

Please visit our site to enter again for next month's drawing

CLicke here : http://www.mydomain.com/enter_to_win.cfm
</cfmail>
</cfloop>
0
 

Author Comment

by:IShiva
ID: 11884413
i understand what youre coding there. but how do i implement that into my admin area of my site? i dont see any html code in there? maybe im just confused. foir example, when i am ready to choose a winner....how do i actually choose one?

also, i just thought of this....what if someone tries to enter twice? can we prevent that by checking their email address to see if it already exists??  thanks again for your help and understanding
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 11884581
".what if someone tries to enter twice? can we prevent that by checking their email address to see if it already exists?? "

Sure - just perform a lookup to see if they already entered before you add them to the entry table.

As for the choosing a winner.  That code does it and sends an email.

How you access the code is up to you.  You could just call the page.  You could have a process call the page.  You could make a button on the page you have to click as an admin that then displays the page.

I didn't write the whole thing for you.  You need to attempt that - or hire someone to do it for you.  I just gave you some code in the CF part to get you started.
0
 

Author Comment

by:IShiva
ID: 11884619
ok, would the email check be a <cfif> tag to check for this before it takes the data and writes it to the DB?
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 11884858
yep.

you would have a query like :

<cfquery datasource="mydsn" name="checkforduplicate">
SELECT * FROM entrytable
WHERE email = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.email#">
</cfquery>

<cfif checkforduplicate.recordcount GT 0>
You already entered this drawing - come back next month
<cfelse>
<cfquery datasource="mydsn" name="checkforduplicate">
INSERT INTO entrytable (FirstName, LastName, email, etc.....)
VALUES(<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.firstname#">,
<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.lastname#">,
<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.email#">,
etc...)
</cfquery>
</cfif>
0

Featured Post

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question