Solved

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

Posted on 2004-08-24
8
295 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
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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.

Join & Write a Comment

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now