Solved

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

Posted on 2004-08-24
8
316 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
  • 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
WSUS Client Issues 52 1,649
Website Test Question 6 115
Problem to Eclipse 16 125
Use System DSN 6 87
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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