Solved

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

Posted on 2004-08-24
8
339 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
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 
LVL 35

Accepted Solution

by:
mrichmon earned 125 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
What You Need to Know when Searching for a Webhost Provider
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

705 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