Jump to content

Profile Rate System - Very Primitive!


Jumpy09

Recommended Posts

Okay so this is a rating script which works currently.  I just don't quite like the POST set up and could use some help getting it switched over to a different method.

 

$points1 = '10';
$points2 = '5';

echo '		<form id="rates_profile" action="?page=profile&uid=' . $uid . '" method="POST">
					<input type="hidden" name="points" value="' . $points1 . '">
					<input type="hidden" name="points2" value="' . $points2 . '">
					<input style="width: 20px; height: 20px;" class="rates" type="submit" name="profilerate" value="1">
					<input style="width: 20px; height: 20px;" class="rates" type="submit" name="profilerate" value="2">
					<input style="width: 20px; height: 20px;" class="rates" type="submit" name="profilerate" value="3">
					<input style="width: 20px; height: 20px;" class="rates" type="submit" name="profilerate" value="4">
					<input style="width: 20px; height: 20px;" class="rates" type="submit" name="profilerate" value="5">
					<input style="width: 20px; height: 20px;" class="rates" type="submit" name="profilerate" value="6">
					<input style="width: 20px; height: 20px;" class="rates" type="submit" name="profilerate" value="7">
					<input style="width: 20px; height: 20px;" class="rates" type="submit" name="profilerate" value="8">
					<input style="width: 20px; height: 20px;" class="rates" type="submit" name="profilerate" value="9">
					<input style="width: 20px; height: 20px;" class="rates" type="submit" name="profilerate" value="10">';
				if($session->isAdmin()){
echo '			<input style="width: 20px; height: 20px;" class="rates" type="submit" name="profilerate" value="11">';
				}
echo '			</form>';



if($_POST['profilerate']) {

$uid = $_GET['uid'];
$uid2= uid($session->username);
$points1 = $_POST['points'];
$points2 = $_POST['points2'];
$rate = $_POST['profilerate'];

if($uid == $uid2) {
$error = 'You can\'t rate yourself, what are you thinking?';
} else {

$query=mysql_query("SELECT * FROM `rates_profile` WHERE uid = '$uid2' AND rateduid = '$uid'");
$num=mysql_num_rows($query);

if($num == 0) {
$insert = mysql_query("INSERT INTO `rates_profile` (uid, rateduid, rate, date) VALUES ('$uid2', '$uid', '$rate', NOW())");
	if($insert == true) {
			$inserttotalrates=mysql_query("UPDATE `users` SET silver = silver + " . $points1 . ", points = points + " . $points1 . ", profilerates = profilerates + 1 WHERE uid = '$uid'") or die(mysql_error());
			if($inserttotalrates == true) {
				$insertpoints=mysql_query("UPDATE `users` SET silver = silver + " . $points2 . ", points = points + " . $points2 . " WHERE uid = '$uid2'");
					if($insertpoints == true) {
				$error = 'Congratulations, you have rated this user a/an "' . $rate . '" and earned ' . $points2 . ' Points!';
				} else {
				$error = 'Points have not been entered!';
			}
			}
	} else if($insert == false) {
		$error = 'The rate was not submitted, please try again.  If you get this error again, please inform an Admin.';
	} else {
		$error = 'You should never see this!';
	}
} else if($num > 0) {
$updaterate = mysql_query("UPDATE `rates_profile` SET rate = '$rate' WHERE uid = '$uid2' AND rateduid = '$uid'");
} else {
$error = 'You really fucked something up to see this!';
}
}
echo $error;

}

 

What happens is the profile have 1 - 10 and if Admin 1- 11.  A person clicks on it, and it grants points to both parties.  This all works, but I want to remove the post and come up with a way that I could have two images.. and depending on the rate will depend on how many lit up images are shown.

 

For Example:

 

Unrated User would have 11 grayed out images.  If I rate bob a 2, to me he will have 2 lit up images and 9 grayed out images.

 

I can't quite figure out another method of getting this to function in that manner.

 

Thanks in Advance!

 

Note: I code to functionality, it functions so I did it that way.  I don't want a $_GET['blah'] because I feel it would be pointless with a rating system.  Sorry if it looks like crap.

 

Edit: $points and $points2 are temporary.  I plan on coding an entire point system which will replace that.

Link to comment
https://forums.phpfreaks.com/topic/204681-profile-rate-system-very-primitive/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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