We’d like to remind Forumites to please avoid political debate on the Forum.

This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.

📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

help building online competition

hi, was wondering if anyone can help me (go easy on me if I get the technical terms completely wrong as I'm posting for a friend).
Basically my friend has to build an online competition using php, so far he has build the basic page and when people submit their email it is added to a word file. On the page he has the time of the server showing but isn't sure how to set a closing date for the competition - can anyone help?
Also, how does he go about getting the software to pick one random name and put it into another file?

(p.s this isn't a real competition its more of a mini test to help build his experience)

Comments

  • InsideInsurance
    InsideInsurance Posts: 22,460 Forumite
    10,000 Posts Combo Breaker
    Normally you would use a database rather than a text file (MySQL if he is using PHP).

    Personally dont use PHP but the logic is the same no matter the language, you'd simply have an IF THEN ELSE type statement. Define a variable with the end date. Check IF the date now is before the stated end date variable, if it is THEN show the submission form ELSE show the competitions ended text or redirect them to such a page.

    Alternatively just check if the date is equal to or greater than the end date and redirect to the end of competition page

    Using a text file to pick a winner I would count the number of lines and then generate a random number between 1 and the line count and then return that line as the winner and store it into a new file.
  • paddyrg
    paddyrg Posts: 13,543 Forumite
    This question is a bit bigger than a forum post can answer, I suggest - especially if it is Chinese Whispers friend to friend. Programming PHP or any language is as much about architecture and design as syntax, and that's a big deal.

    On a quick-fix front - use a chron job to rename the php/webpage from 'compo.php to dead.php, and rename compoclosed.php to compo.php ;-)
  • libra10
    libra10 Posts: 19,669 Forumite
    Part of the Furniture 10,000 Posts Name Dropper Photogenic
    There's a random number generator here.

    http://www.mathgoodies.com/calculators/random_no_custom.html

    HTH
  • thanks for the replies! my brother was actually applying for a job and they asked him to build a competition using word, and he has only ever done it using a database & hes graduating (hopefully) in a few weeks so hasn't had any experience with it. once again apologies if anything i've written doesn't make sense as its double dutch to me lol.

    thanks again :)
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 351.7K Banking & Borrowing
  • 253.4K Reduce Debt & Boost Income
  • 454K Spending & Discounts
  • 244.7K Work, Benefits & Business
  • 600.1K Mortgages, Homes & Bills
  • 177.3K Life & Family
  • 258.3K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.2K Discuss & Feedback
  • 37.6K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.