hi everyone , i have an ajax rating system on my website , the problem is only users can rate and if you don't login you can't rate . i wanna remove this login part to all the viewers can rate without need to create account and login to it , because there is so few peoples do it just for a rating , so here is the code :
and this one on wallpaper_main.phpCode:<?php include '../../../config.php'; include '../../core.php'; $id = intval($_POST['id']); $userid = intval($_COOKIE['wss_userid']); if (isset($_COOKIE["wss_username"])) { $user_rated_yet = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM wss_ratings WHERE user_id='$userid' AND wallpaper_id='$id'"), 0); if ($user_rated_yet >= 1) { echo ALREADY_RATED; } else { $wss_userid = intval($_COOKIE['wss_userid']); $rating = intval($_POST['rating']); if ($_POST['rating'] > 5 || $_POST['rating'] < 0) { echo 'Nope'; exit(); } $sql = mysql_query("SELECT * FROM wss_users WHERE id=".$userid.""); $row = mysql_fetch_array($sql); if ($row['password'] == $_COOKIE['wss_code']) { mysql_query("INSERT INTO wss_ratings (wallpaper_id, user_id, rating, ip) VALUES ('$id', '$wss_userid', '$rating', '$_SERVER[REMOTE_ADDR]')"); $no_of_ratings = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM wss_ratings WHERE wallpaper_id='$id'"),0); $get_ratings = mysql_query("SELECT sum(rating) AS rating FROM wss_ratings WHERE wallpaper_id='$id'"); $ratings_sum = mysql_fetch_array($get_ratings); $rating = ($ratings_sum['rating'] / $no_of_ratings); mysql_query("UPDATE wss_wallpapers SET rating='$rating' WHERE id='$id'") or die (mysql_error()); mysql_query("UPDATE wss_users SET ratings = ratings + 1 WHERE id='".$userid."'") or die (mysql_error()); } } } ?>
it's most important thing for me but if it possible i wanna something else , this is rating system for a wallpaper script , the other thing that i wan it is a code to show the rate of wallpaper on thumbnail , no you can just see the rate of wallpaper when you click on it and go to select resolution page , the rating ajax code is above and here is the code that display the rate on resolution page :Code:// Define the 'new rating' section for the template if(isset($_COOKIE["wss_username"])) { $user_rated_yet = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM wss_ratings WHERE user_id='$user[id]' AND wallpaper_id='$id'"), 0); if ($user_rated_yet >= 1) { $ur = mysql_query("SELECT * FROM wss_ratings WHERE wallpaper_id=$id AND user_id='$user[id]'"); $user_rating = mysql_fetch_array($ur); $wallpaper['new_rating_form'] = GenerateRating($user_rating['rating'], 'wallpaper'); } else { $wallpaper['new_rating_form'] = '<div id="rateMe" title="Rate Me..."> <a onclick="rateIt(this, '.$id.", '".$setting['site_url']."'".')" id="_1" title="1" onmouseover="rating(this)" onmouseout="off(this)"></a> <a onclick="rateIt(this, '.$id.", '".$setting['site_url']."'".')" id="_2" title="2" onmouseover="rating(this)" onmouseout="off(this)"></a> <a onclick="rateIt(this, '.$id.", '".$setting['site_url']."'".')" id="_3" title="3" onmouseover="rating(this)" onmouseout="off(this)"></a> <a onclick="rateIt(this, '.$id.", '".$setting['site_url']."'".')" id="_4" title="4" onmouseover="rating(this)" onmouseout="off(this)"></a> <a onclick="rateIt(this, '.$id.", '".$setting['site_url']."'".')" id="_5" title="5" onmouseover="rating(this)" onmouseout="off(this)"></a> </div>'; } } else { $wallpaper['new_rating_form'] = WALLPAPER_LOGIN_TO_RATE; }
i wanna make it display beside the name of wallpaper in this code :Code:<div class="wallpaper_info_right"> <?php echo '<div class="info_item_right">'.WALLPAPER_RATING.'<br />'.$wallpaper['rating_image'].'</div>';?> </div>
Code:<div class="wallpaper_item2"> <a href="<?php echo $wallpaper['url'];?>"> <img src="<?php echo $wallpaper['thumbnail'];?>" alt="<?php echo $wallpaper['name'];?>" width="180" height="102" /> <div class="wallpaper_item2_name"> <?php if ($setting['show_names'] == 1) { echo $wallpaper['rating_image']; } else { echo INFO_AND_DOWNLOAD_LINK; } ?> </div> </a> </div>
and here is the example site that did everything that i'm searching for it , he removed login request for rating , and make it display rate of wallpapers on thumbnails :
http://www.winhdwallpapers.com/funny/keep-calm
please help me i really need this![]()



Reply With Quote
Bookmarks