Jump to content

Ratings Bar Help


mikemalphurs

Recommended Posts

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;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.