Professional Web Applications Themes

3 mins of your time please...logic problem - PHP Development

Hi all, Am having a bit of a problem understanding this, can anybody tell me where i'm going wrong please? Basically trying to limit the "vote" to just 1 per person, first am checking if the the person with username has voted, if that comes back as false then am checking his ip (because i dont know if the person changed his username and is trying to vote again) now its allowing me to vote twice and on the third time its restricting me. *****************code************* $check="select vote_date from site_rateing where user='".$username."' and sitenumber=".$n; $res = mysql_query($check) or die("Error: " . ...

  1. #1

    Default 3 mins of your time please...logic problem

    Hi all,
    Am having a bit of a problem understanding this, can anybody tell me where
    i'm going wrong please?

    Basically trying to limit the "vote" to just 1 per person, first am checking
    if the the person with username has voted, if that comes back as false then
    am checking his ip (because i dont know if the person changed his username
    and is trying to vote again) now its allowing me to vote twice and on the
    third time its restricting me.

    *****************code*************
    $check="select vote_date from site_rateing where user='".$username."' and
    sitenumber=".$n;
    $res = mysql_query($check) or die("Error: " . mysql_error());
    $check_result = mysql_num_rows($res);

    if($check_result !=1)
    { $oneVote=1;

    $check2="select count(*) from site_rateing where ipno='".$theIP."' and
    sitenumber=".$n;
    $check_result2 = mysql_result(mysql_query($check2),0);

    if($check_result2 >=1)
    { $oneVote=2;}else{$oneVote=1;}

    }// end of first "if"


    if($oneVote ==2)
    {
    $row = mysql_fetch_row($res);
    print("Sorry, You have already voted on ".$row[0].".<br> Only one vote
    is allowed");
    exit;
    }
    else
    //continue with the program.
    *****************code*************

    Any ideas?

    Thanks,
    -Ryan
    Ryan A Guest

  2. #2

    Default Re: [PHP] 3 mins of your time please...logic problem

    From: "Ryan A" <ryancoinpass.com>
    > Basically trying to limit the "vote" to just 1 per person, first am
    checking
    > if the the person with username has voted, if that comes back as false
    then
    > am checking his ip (because i dont know if the person changed his
    username
    > and is trying to vote again) now its allowing me to vote twice and on the
    > third time its restricting me.
    Just get rid of the check for IP address. All you're going to do is restrict
    a bunch of people that actually haven't voted just because they have the
    same IP address as someone else. Some ISPs have it so that all requests look
    like they are coming from the same IP address while it's actually different
    people.

    If your "poll" is really so important that you need to limit people from
    voting twice, then make them log in and only allow one vote per username.

    ---John Holmes...
    Cpt John W. Holmes Guest

  3. #3

    Default RE: [PHP] 3 mins of your time please...logic problem

    Hi,

    Another way to restrict them to one vote is to set a cookie. Although not
    completely full-proof, its a method I've seen a lot of them use.

    -Dan Joseph
    > -----Original Message-----
    > From: CPT John W. Holmes [mailto:holmes072000charter.net]
    > Sent: Wednesday, September 24, 2003 1:54 PM
    > To: Ryan A; [email]php-generallists.php.net[/email]
    > Subject: Re: [PHP] 3 mins of your time please...logic problem
    >
    >
    > From: "Ryan A" <ryancoinpass.com>
    >
    > > Basically trying to limit the "vote" to just 1 per person, first am
    > checking
    > > if the the person with username has voted, if that comes back as false
    > then
    > > am checking his ip (because i dont know if the person changed his
    > username
    > > and is trying to vote again) now its allowing me to vote twice
    > and on the
    > > third time its restricting me.
    >
    > Just get rid of the check for IP address. All you're going to do
    > is restrict
    > a bunch of people that actually haven't voted just because they have the
    > same IP address as someone else. Some ISPs have it so that all
    > requests look
    > like they are coming from the same IP address while it's actually
    > different
    > people.
    >
    > If your "poll" is really so important that you need to limit people from
    > voting twice, then make them log in and only allow one vote per username.
    >
    > ---John Holmes...
    >
    > --
    > PHP General Mailing List (http://www.php.net/)
    > To unsubscribe, visit: http://www.php.net/unsub.php
    >
    Dan Joseph Guest

  4. #4

    Default RE: [PHP] 3 mins of your time please...logic problem

    --- Dan Joseph <djosephduhq.us> wrote:
    > Another way to restrict them to one vote is to set a cookie.
    > Although not completely full-proof, its a method I've seen a lot
    > of them use.
    That's way too easy to avoid. You might rule out the bottom 50% of the computer
    illiterate, but these are probably the people who are having trouble casting
    their vote once, much less trying to cast a second vote.

    Also, while "everyone else is doing it" is a good reason to at least research a
    particular method, it's not a good reason to choose it.

    Hope that helps.

    Chris

    =====
    Become a better Web developer with the HTTP Developer's Handbook
    [url]http://httphandbook.org/[/url]
    Chris Shiflett Guest

  5. #5

    Default Re: [PHP] 3 mins of your time please...logic problem

    Hey John,
    Thats already done, the user has to authenticate his address by clicking on
    the link which contains his $CNO and $random_number
    But the rateing system is for webhosts, and webhosts usually have a catch
    all email address so they can use n number of email addresses....

    Cheers,
    -Ryan

    > So make your registration process do the work and ensure users are unique,
    > not the poll engine. Have them supply an email address that they must
    reply
    > to (or click a link within) in order to validate. Get one of those image
    > programs where you have to type in the letters/numbers off the image
    that'll
    > stop automatic registrations. Make sure everything important is done over
    > SSL.
    >
    > ---John Holmes...
    >
    >
    >
    Ryan A Guest

  6. #6

    Default Re: [PHP] 3 mins of your time please...logic problem

    On Thursday 25 September 2003 04:03, Ryan A wrote:
    > Thats already done, the user has to authenticate his address by clicking on
    > the link which contains his $CNO and $random_number
    > But the rateing system is for webhosts, and webhosts usually have a catch
    > all email address so they can use n number of email addresses....
    Make the voting process tedious and non-automatable. Eg generate an image with
    some fuzzy characters embedded and ask the voter to enter the letters.

    --
    Jason Wong -> Gremlins Associates -> [url]www.gremlins.biz[/url]
    Open Source Software Systems Integrators
    * Web Design & Hosting * Internet & Intranet Applications Development *
    ------------------------------------------
    Search the list archives before you post
    [url]http://marc.theaimsgroup.com/?l=php-general[/url]
    ------------------------------------------
    /*
    Alimony is a system by which, when two people make a mistake, one of them
    continues to pay for it.
    -- Peggy Joyce
    */
    Jason Wong Guest

  7. Moderated Post

    Default Re: [PHP] 3 mins of your time please...logic problem

    Removed by Administrator
    Ryan A Guest
    Moderated Post

  8. Moderated Post

    Default Re: [PHP] 3 mins of your time please...logic problem

    Removed by Administrator
    Jason Wong Guest
    Moderated Post

  9. Moderated Post

    Default Re: [PHP] 3 mins of your time please...logic problem

    Removed by Administrator
    Ryan A Guest
    Moderated Post

  10. #10

    Default Re: [PHP] 3 mins of your time please...logic problem

    On Thursday 25 September 2003 05:44, Ryan A wrote:
    > Can you give me any links for generating blurry images that can be human
    > identified quickly but not so easy by automation?
    There's a class in [url]www.phpclasses.org[/url] which help you generate such images,
    I've no idea how good it is.

    It's pretty straightforward to write your own using the image functions:

    1) create a new image

    2) set a background colour

    3) create some random characters, using random fonts, random colour (limit the
    set of colours to choose from so it doesn't disappear into the background),
    and small amount of random rotation

    4) for good measure sprinkle the image liberally with randomly coloured
    pixels.

    --
    Jason Wong -> Gremlins Associates -> [url]www.gremlins.biz[/url]
    Open Source Software Systems Integrators
    * Web Design & Hosting * Internet & Intranet Applications Development *
    ------------------------------------------
    Search the list archives before you post
    [url]http://marc.theaimsgroup.com/?l=php-general[/url]
    ------------------------------------------
    /*
    Question: Is it better to abide by the rules until they're changed or
    help speed the change by breaking them?
    */
    Jason Wong Guest

Similar Threads

  1. CMS logic problem
    By Astra in forum ASP Database
    Replies: 0
    Last Post: April 22nd, 09:44 AM
  2. Updating imported image takes 2 mins. if tiff is more than 20 megs????
    By trostokosmatih webforumsuser@macromedia.com in forum Macromedia Freehand
    Replies: 2
    Last Post: September 30th, 03:29 PM
  3. [PHP] 3 mins of your time please...logic problem
    By Jeremy Russell in forum PHP Development
    Replies: 12
    Last Post: September 25th, 01:42 PM
  4. chris->[PHP] 3 mins of your time please...logic problem
    By Chris Shiflett in forum PHP Development
    Replies: 2
    Last Post: September 25th, 12:12 AM
  5. Formatting a time field to 24 hour time (Military time) in the Datagrid
    By David Hearn in forum ASP.NET Data Grid Control
    Replies: 1
    Last Post: September 10th, 02:50 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139