Forum Moderators: coopster

Message Too Old, No Replies

Competition entry form / random entry draw script with PHP?

         

Timboo

6:32 am on Aug 12, 2004 (gmt 0)

10+ Year Member



Hello all from Australia!

I'm looking for an easy method to implement an 'entry form' for an online competition on my website (a competition page, if you like).

As I am running a 'trade promotion' I will need to apply for a trade permit license, therefore will need to satisfy the local authorities that the entry form and drawing method are acceptible.

The competition page will feature the prize on offer and the fields for entrants to fill in their details.

The tricky part I think is that I then require the entries to be able to be 'drawn randomly' once the competition has ended. Any tips here on how to successfully and easily run a competition from your site?

Many thanks to all in advance

jatar_k

5:15 pm on Aug 12, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



are you going to store the entries in a db

one possibility

each entry has a unique id attributed to it on insert.
if the first one is 1 and you

select max(entry_id) as lastentry from yourtable;

you will now have the range of entries to pull from randomly. You could then do something similar to this

$winner = rand(1,$lastentry);
select * from yourtable where entry_id=$winner;

You would just have to handle it in case that particular id doesn't exist.

you could also pull randomly using the query itself but I just didn't go that way. ;)