Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Raffle script to reward Voters

  1. #1
    Join Date
    Aug 2011
    Location
    Rep Of Ireland
    Posts
    126
    Thanks
    24
    Thanked 3 Times in 1 Post

    Default Raffle script to reward Voters

    Running a (local area) poll on a website which records ip address (to a flat file) to prevent multiple votes .

    I seek to make arrangements to provide a reward incentive for voting.

    Could a prize be given further to a random ip address selection at the end of the poll. The winning ip address could be published on the website thus enabling winner to claim prize.

    Question 1. Is such a thing possible!
    Question 2. Are computer users familiar with their ip addresses?
    Question 3. How would a person prove that their computer was the winner?
    Question 4. What software or script would make the random selection from the ip addresses?

    Thanks in advance.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    There's a much simpler and more reliable option: have them submit their email address when they vote. Then you can contact whoever wins by email. That's reliable and everything already works.


    But to answer your questions:

    Question 1:
    In theory it's possible, but it would not be practical because of a few things. First, IP addresses are not actually unique for each user. If two users share a computer (family members, or even users at an internet cafe or a school), then you won't know which user it was. Second, IP addresses change. They're reliable during a single visit to the website, but they might change every day, or every few weeks, depending on a number of factors (fast for dialup, for example). But more importantly, you would be requiring that users log on from their home computer only, or at least that when they try to claim the prize they'd be on the same computer (which hopefully has not reset its IP, which is unlikely). And mobile devices rotate IPs all the time, so they won't work for this.

    Question 2:
    No, the average internet user does not know their IP address. You could probably fairly easily explain what it is, and you could even use PHP for example to show them their IP. I'm not sure how much you'd really need to explain, but if there was a question about knowing which computer to use, that could be very confusing.
    In short, don't rely on the user understanding this at all. (Some will, so be prepared to know more than them in case they question the fairness of your system.)

    Question 3:
    Well, if they log on from the same IP, then it's probably the same person. That's not entirely true: if the IP rotates, then it might be someone else. If the computer/connection is shared, it might be someone else. But on average the particular users participating in your poll probably won't be "trading" IPs all that often. You might end up with no winners (since the winning IP isn't being used by anyone who knows about the contest at that point), but the odds are against someone "falsely winning" because they received the winning IP. However, the odds actually are a little higher if you are doing this locally because IPs are grouped by geographic location. It's a little more complicated than that, but within every subset of geography (eg, country, city) the IPs tend to be more similar. This is especially true if many of your participants are using the same ISP.

    Question 4:
    Any programming language could do this. You could even do it in Microsoft Excel for example. Or you could do it by hand: just find ANY random number generator and locate the IP on the list at that point (eg, if you get "530" as the random number, find line 530 in your file and use that IP). If you're going to do this a lot I'd recommend approaching it with PHP to automate everything, but there's no reason you NEED to, just to save yourself time. And in fact, I'd recommend using a database instead of flat files, but that's your choice.


    Some more comments:

    1. The faster you do this, the more likely the IPs will not have changed. So if you give out a prize every day to the people that participated that day, the odds are higher that they will still have the same IP address, but it's not guaranteed. If you wait a year (or even a month) there's no point at all: it's almost guaranteed that the IPs have rotated. The only people that have static IPs have that because they want their computer to be located externally, so servers often have static IPs (although not always), but most home computers don't.

    2. How would you let the participants know? "Check back in a while to see if your computer lets you claim a prize?" I don't see how using the IP here is easier. Why not just collect emails like I said?

    3. A more reliable method if you don't want to use emails would be to give each participant a random number. This is just like a lottery/raffle ticket. Tell them to check back and enter their number to see if they've won.

    4. You could ignore these problems and just search for a user whose IP has not changed. So just rotate through a list of potential winners until one of them claims the prize because for some reason their computer is slower to reset its IP than the other computers involved. But this would NOT be fair, because you would be giving out prizes based on who keeps the same IP, not on who is really a random winner. Some participants would never be able to win.

    5. Using IPs to identify participants is always a bad idea because it's easy to cheat. Many users might not understand this, but the odds are that someone will understand. If you use multiple computers, there's no way to link the votes, so one user can vote many times. Especially if there is a prize involved, it's almost guaranteed that they will try to enter multiple times and that then you'd have many IPs for a single person.
    There are two ways to deal with this:
    1) If it isn't a very important poll or something that people would want to cheat on (usually when there isn't a prize), then you can just ignore it. If someone votes twice or three times it won't really matter in the end, as long as you have a high number of participants.
    2) Use email validation. Send a code to the email they submit when voting then only count the vote when the code is re-entered into your site. It's more work, but it's reliable. One vote per email.
    Or, (3), you could create a user login system (or use on from a forum, etc.) if that happens to be easier. One vote per account.

    Note that (2) and (3) don't actually prove that a single person doesn't vote more than once (they might have two emails or two accounts), but it's more difficult, and in the end it will be easier to give them the prize because those will be unique.
    Last edited by djr33; 11-06-2011 at 05:17 PM.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. The Following User Says Thank You to djr33 For This Useful Post:

    Webiter (11-06-2011)

  4. #3
    Join Date
    Aug 2011
    Location
    Rep Of Ireland
    Posts
    126
    Thanks
    24
    Thanked 3 Times in 1 Post

    Default

    Thanks for the detailed response and well that sorted that! Your first sentence seems to give the proper opinion and direction on the matter.
    I am using a DBscript.net PHP Poll script which I like to master the polling. I might be
    Is knitting the email solution into such a script a straightforward or wise option for a one year old webdesigner ?

  5. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    In theory, adding an email input is just one line of code. Making sure that actually gets sent to you is a little more complicated and depends on the system. If you're using a polling script, then look at the script for existing options. If there aren't any, then you'll either need to use another script or modify that one (maybe in a big way or maybe just very slightly). It really depends on the script. Setting up something else (eg, IP addresses or a 'lottery' code) wouldn't really be much easier, so you probably should just figure out how to add the email input.

    Here's the HTML you'd need:
    <input type="text" name="email" />
    Add that inside the <form> tags for your poll.
    And that's all. That will be submitted with the form and received on the server, but unless the script intentionally forwards all submitted fields (it might) or looks for one called "email" specifically, then it probably won't actually be sent to you. But the rest of the modifications will need to take place inside the PHP, not in the HTML. (Unless it is looking for another input name for the email, eg, 'mail' or 'address', etc.)


    By the way, if I were you I'd recommend checking for any duplicated email addresses (meaning they voted two times) then removing them from the potential winners.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #5
    Join Date
    Aug 2011
    Location
    Rep Of Ireland
    Posts
    126
    Thanks
    24
    Thanked 3 Times in 1 Post

    Default

    The poll layout is described as show_vote_control

    PHP Code:
    <title>Polling Booth</title>
    <?php    
        
    require_once('poll/poll.php'); 
    ?>

    <div class="poll"><h3>Poll 3</h3><?php show_vote_control('1'); ?></div>
    It appears that the email input may have to go inside the POLL DEFINATION!
    In config.php POLL DEFINATION is described in the following terms:

    PHP Code:
    $p = new Poll;
    $VALID_POLLS["1"] = $p;                                                // "1" is the poll ID
    $p->legend "Our First Poll";                    // Form legend; leave empty for none
    $p->returnToURL "../booth.php";                // Specify the URL to return to for this poll. 
    $p->control_type $CONTROL_RADIOBUTTONS;        // Control type; $CONTROL_RADIOBUTTONS or $CONTROL_COMBOBOX
    //POLL QUESTION//
    $p->question "Do we need a Town Council?";    
    //POLL ANSWERS//
    $p->add_value("1""Yes");                        
    $p->add_value("2""Probably");
    $p->add_value("3""No");
    $p->add_value("4""Undecided"); 
    and this renders as img attached with the information relevent to the voter input being sent to the flat file.

    Using HTML to install as follows:
    Include your EMAIL to Validate <input type="text" name="email" /> just before the </div> of the <div class="poll"> renders an email input field - how such input might find its way to the flat file along with the vote and the ip detail would resolve!

    Not sure if this helps you to add further comment on task direction!

  7. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    There's a general correlation between ease of use and difficulty of modification, or of ease of modification and difficulty of use. "Do it yourself" things are easy to modify, but hard to use; and pre-made "ready to go" scripts are easy to use, but hard to modify.

    What you have here is a prebuilt script that just might not have the option to add an email field. Or it might, but what you posted isn't "real" code-- it's pseudo-code based on the framework of that script. (It's 'real' PHP code, but not in a way that allows easy modification-- it's all an indirect way for the PHP to eventually generate the real script.)

    Now it's possible that there's a way to add the email field, but I do'nt know how that would work from what you've posted. Do you have a link to the script's documentation? We might be able to help that way. If not, you need to change scripts or hire someone to modify thing one for you.

    Another option that might work is the following:
    After they vote on the poll, ask for an email address to enter them into the contest. Then that is stored independently of the votes. This way, you won't need to integrate it at all. It's not a perfect solution, but might be easiest for you given the circumstances.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #7
    Join Date
    Aug 2011
    Location
    Rep Of Ireland
    Posts
    126
    Thanks
    24
    Thanked 3 Times in 1 Post

    Default

    djr33 said "After they vote on the poll, ask for an email address to enter them into the contest. Then that is stored independently of the votes. This way, you won't need to integrate it at all".
    I like this approach as voting would be occasional, lasting about a week and I only seek to encourage by adding a reward facility. (Our committee could get some supermarket to sponsor a food hamper or something like that when required). Requesting the addition of the email to enter the raffle would be a simple and straightforward way out. It also gives the added impression that we know what we are doing!!... advice from my old schoolteacher and yes, its better not to tamper with the working poll script.

    Could the emails associated with the polling be easily collected to a seperate flat file (do not want to bother with mySql just yet) and where might the email form be sending to?

    This is getting close to the principles used in having the detail on a contact form being sent to an email address, except in this case we want to try and get it deposited in a file! You might be better able if possible to sketch the roadmap to such a resolve.

  9. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,162
    Thanks
    263
    Thanked 690 Times in 678 Posts

    Default

    Using MySQL would be better for organizational purposes, such as quickly finding a random email to give the prize to. But you don't really need it-- if you use a flat file you'd just get a list of emails then you could randomly select one yourself (eg, open the list in a program that has line numbers then use a random number generator to find the one you want to pick).

    Here's the relevant information. It's not necessarily "easy", but it's pretty basic/standard PHP so you should be able to put it together from a few basic examples.

    First, you'll need to make an HTML form. Then add a text input (like I had in my earlier post) and give it a name you'll remember-- 'email' is fine.

    Next, on the PHP page you'll need to receive that value:
    $email = $_POST['email'];
    But (this is a little advanced) you'll want to be sure that:
    --1) something WAS submitted
    $email = !empty($_POST['email'])?$_POST['email'];
    --2) it doesn't contain any 'funny' characters. Actually, if this is JUST a text file, it won't matter. So I'll skip it-- but look into 'escaping' if you need to use this in a database or later display it on an HTML page. You could use htmlspecialchars() to remove <, >, & and ", for example. Or you could use mysql_real_escape_string() to make it safe for a database.

    Then you have the variable $email all ready to go-- just insert it into a text file.
    http://www.php.net/manual/en/function.fwrite.php
    There's documentation there about how to do this and some example scripts.
    Some extra info:
    1. You will need to make sure PHP has write permissions on the file. The easiest way to do this is to create a new file (via FTP, for example) and set its permissions specifically to 755 or 777 (CHMOD). Look up 'chmod' if you don't know how to do this. It's a little confusing, but not difficult.
    2. You will want to look at the writing mode. You could read the contents of the text file, then add the new email to the end, then write all of that back to the text file. But the simpler way would be to use one of the writing modes that just adds the contents to the end: each time you use fwrite() it just adds that next email as a new line in the file.
    3. To specify a new line, you'll need to use "\n" (in DOUBLE quotes-- not single quotes), or you could just add a real new line in the string. Some examples:
    PHP Code:
    $email $email."\n"//add a line break after.
    $email $email.'
    '
    //add a line break after 
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. The Following User Says Thank You to djr33 For This Useful Post:

    Webiter (11-11-2011)

  11. #9
    Join Date
    Aug 2011
    Location
    Rep Of Ireland
    Posts
    126
    Thanks
    24
    Thanked 3 Times in 1 Post

    Default

    My index.php consists of straightforward inputs. Now added name and phone.

    Processing as follows in raffleinfo.php

    PHP Code:
    <?php
    $vname 
    $_GET["name"];
    $vemail $_GET["email"];
    $vphone $_GET["phone"];
    print(
    "<b>Thank You!</b><br />Your information will be entered once into the raffle!");
    $out fopen("savedinfo.php""a");  //what is this "a" doing?
    if (!$out) {
    print(
    "Could not add details to the database");
    exit;
    }
    fputs ($out,"\n");   //add a line break after.
    fwrite($out,"$vname$vemail$vphone.");
    fclose($out);
    ?>
    Currently running the files in wamp and collected info being captured in savedinfo.php (or the flatfile) as required.

    Thanks Daniel for your efforts and guidance with this query. You pulled me off the wrong track ane positioned me on the right track. Cheers.
    Last edited by Webiter; 11-09-2011 at 08:03 PM. Reason: Managed to resolve the query.

  12. #10
    Join Date
    Aug 2011
    Location
    Rep Of Ireland
    Posts
    126
    Thanks
    24
    Thanked 3 Times in 1 Post

    Default

    I present this just to present the question at the end of this post.

    Presented alongside a polling facility on a webpage is the following input fields that enables the visitor (voter) to enter their details in a raffle for a hamper as a reward for their effort in taking part in the poll.

    The raffle entry form script is not attached to the poll script. All inputs in the raffle entry form script are validated and the info is sent to a flatfile. It is a short poll lasting only 7 days on different topics that might arise from time to time for a small town forum. (ip is also collected)

    HTML Code:
    Name  :<input type="text" name="visitor" /><br /><br />
    Email :<input type="text" name="visitormail" /><br /><br />
    Phone :<input type="text" name="visitorphone"/><br /><br />
    On submission the 'Thank You' page advises the visitor that their details will be used once in the raffle for the hamper.

    In other words the visitor could go back and fill in the form again and submit, requiring that I check for and weed out multiple or repeat entries from the flatfile before completing the Random Number draw for the hamper! Such a task would not be the end of the world but it might be tedious.

    The Question Is there a simple way based on the info collected to install something that in some way prevents the visitor from attempting multiple entries into the draw? It would not have to be 100% but it might save me some time on a tedious activity!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •