Location: PHPKode > projects > MyBlog: PHP and MySQL Blog/CMS software > os/vote.php
<?php 
$postid = $_GET['id'];
$mid = $_GET['mid'];


setcookie("vote", $postid, time()+6000000000000000000000, "/");
require("config/mysqlconnection.inc");

if($_COOKIE['vote'] == $postid && isset($_COOKIE['vote'])) {
echo "You have already voted! Please share your votes around!";
exit;
}

$postid = $_GET['id'];

$result = mysql_query("SELECT * FROM myblog_posts WHERE title = '$postid'") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$member = $row['name'];
}


$result = mysql_query("SELECT * FROM myblog_posts WHERE title = '$postid'") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$existing = $row['rating'];
}

$result = mysql_query("SELECT * FROM myblog_users WHERE user = '$mid'") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$ekudos = $row['kudos'];
}


$add = 1;
$new = $existing + $add;



$newk = $ekudos + "1";


$result2 = mysql_query("UPDATE myblog_posts SET rating='$new' WHERE title = '$postid'") 
or die(mysql_error()); 

$result2 = mysql_query("UPDATE myblog_users SET kudos='$newk' WHERE user = '$member'") 
or die(mysql_error()); 

echo "Thank you for saying you liked this post! <a href=\"index.php\">Go Back.</a>";

 
?>


Return current item: MyBlog: PHP and MySQL Blog/CMS software