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
Solved

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

Posted on 2004-08-24
8
323 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
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…

860 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