Jump to content

mikemalphurs

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mikemalphurs's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello- I have created a website that uses a PHP rating bar system... It is similar to what you would find on Netflix. I am running into an issue with cookies set by the script. In a nutshell, I am trying to allow visitors to vote only once per 24 hour period of time. When I set the code to the below, it works perfectly in IE7. But, in all other browsers and platforms, the ratings stop increasing. So, for example, the vote count does not increase by 1 when you vote in Firefox, Safari, etc. But it does in IE7. It appears that it is a Javascript compatibility issue. I have set only one page on the site to use this version of the script, which you can see at www.AllUglyTeam.com/Coaches2.php. All the rest of the pages lock voters out permanently when they vote the first time. If anyone would know how to modify the script to work correctly or how I could set it up to work server side, I would greatly appreciate it. // For the Javascript function sndReq(vote,id_num,ip_num,units) { var theUL = document.getElementById(’unit_ul’+id_num); // the UL // switch UL with a loading div theUL.innerHTML = ‘’; xmlhttp.open(’get’, ‘rpc.php?j=’+vote+’&q=’+id_num+’&t=’+ip_num+’&c=’+units); xmlhttp.onreadystatechange = handleResponse; xmlhttp.send(null); var cookieName = ‘rater_’ + id_num; var cookieValue = ‘’ + vote; var today = new Date(); var expire = new Date(); nDays=30; expire.setTime(today.getTime() + 3600000*24*nDays); document.cookie = cookieName+’='+escape(cookieValue) + ‘;expires=’+expire.toGMTString(); } //For the _drawrating.php script(check if voted by looking at cookie) // determine whether the user has voted, so we know how to draw the ul/li //$voted=mysql_num_rows(mysql_query(”SELECT used_ips FROM $tableName WHERE used_ips LIKE ‘%”.$ip.”%’ AND id=’”.$id.”‘ “)); if ( $_COOKIE[ “rater_$id” ] ) { $voted=$_COOKIE[ “rater_$id” ]; } else { $voted=0; }
  2. Thanks for your help and suggestion.. I'll post there.
  3. Hello- I have created a website that uses a PHP rating bar system... It is similar to what you would find on Netflix. I am running into an issue with cookies set by the script. In a nutshell, I am trying to allow visitors to vote only once per 24 hour period of time. When I set the code to the below, it works perfectly in IE7. But, in all other browsers and platforms, the ratings stop increasing. So, for example, the vote count does not increase by 1 when you vote in Firefox, Safari, etc. But it does in IE7. I have set only one page on the site to use this version of the script (www.AllUglyTeam.com/Coaches2.php. All the rest of the pages lock voters out permanently when they vote the first time. Any help would be much appreciated. // For the Javascript function sndReq(vote,id_num,ip_num,units) { var theUL = document.getElementById(’unit_ul’+id_num); // the UL // switch UL with a loading div theUL.innerHTML = ‘’; xmlhttp.open(’get’, ‘rpc.php?j=’+vote+’&q=’+id_num+’&t=’+ip_num+’&c=’+units); xmlhttp.onreadystatechange = handleResponse; xmlhttp.send(null); var cookieName = ‘rater_’ + id_num; var cookieValue = ‘’ + vote; var today = new Date(); var expire = new Date(); nDays=30; expire.setTime(today.getTime() + 3600000*24*nDays); document.cookie = cookieName+’='+escape(cookieValue) + ‘;expires=’+expire.toGMTString(); } //For the _drawrating.php script(check if voted by looking at cookie) // determine whether the user has voted, so we know how to draw the ul/li //$voted=mysql_num_rows(mysql_query(”SELECT used_ips FROM $tableName WHERE used_ips LIKE ‘%”.$ip.”%’ AND id=’”.$id.”‘ “)); if ( $_COOKIE[ “rater_$id” ] ) { $voted=$_COOKIE[ “rater_$id” ]; } else { $voted=0; }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.