Advanced Search

Results 1 to 2 of 2

Thread: need help for changing an ajax rating system

  1. #1
    Join Date
    Aug 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question need help for changing an ajax rating system

    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 :

    Code:
    <?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());
    							
    		}
    	}
    }
    
    ?>
    and this one on wallpaper_main.php

    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;
    }
    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:
    <div class="wallpaper_info_right">
    					<?php echo '<div class="info_item_right">'.WALLPAPER_RATING.'<br />'.$wallpaper['rating_image'].'</div>';?> </div>
    i wanna make it display beside the name of wallpaper in this code :

    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
    Last edited by Beverleyh; 08-21-2013 at 05:56 AM. Reason: Formatting

  2. #2
    Join Date
    Aug 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    please some one help me , i tried so many other rating systems but none of them working on this script , i don't know why maybe it's because i'm completely noob but i did everything step by step but they didn't work and this one works but just with username and when i do any changes on this script it doesn't work anymore , i know it's a big ask , but i really don't have any other way , please guys pleeeeeeease help me

Similar Threads

  1. Rating system
    By Jay Dog in forum Looking for such a script or service
    Replies: 3
    Last Post: 03-04-2013, 03:49 PM
  2. Feedback Rating system
    By Aaron in forum Looking for such a script or service
    Replies: 0
    Last Post: 02-28-2008, 09:37 PM
  3. That 5 Star Rating System
    By Elmo in forum Other
    Replies: 1
    Last Post: 07-10-2006, 06:41 AM
  4. Rating System
    By Wondervideo in forum PHP
    Replies: 6
    Last Post: 05-18-2006, 09:08 PM
  5. Rating System
    By Wondervideo in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 05-15-2006, 05:11 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
  •