Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
625 views
in Q2A Core by
edited by

up_vote.php like down_vote.php

//HTML Code
<?php
include("qa_config.php");
$ip=$_SERVER['REMOTE_ADDR'];

if($_POST['id'])
{
$id=$_POST['id'];
$id = mysql_escape_String($id);
//Verify IP address in Voting_IP table
$ip_sql=mysql_query("select ip_add from Voting_IP where mes_id_fk='$id' and ip_add='$ip'");
$count=mysql_num_rows($ip_sql);

if($count==0)
{
// Update Vote.
$sql = "update Messages set up=up+1 where mes_id='$id'";
mysql_query( $sql);
// Insert IP address and Message Id in Voting_IP table.
$sql_in = "insert into Voting_IP (mes_id_fk,ip_add) values ('$id','$ip')";
mysql_query( $sql_in);
echo "<script>alert('Thanks for the vote');</script>";
}
else
{
echo "<script>alert('You have already voted');</script>";
}

$result=mysql_query("select up from Messages where mes_id='$id'");
$row=mysql_fetch_array($result);
$up_value=$row['up'];
echo $up_value;

}
?>


???????????

1 Answer

0 votes
by
Looks promising - maybe you will release it as a plugin?
by
Thanks, gidgreen, for fun! ) But I am not an programmer, I do not know how to do that.
by
edited by
I am about voting. If somebody wants to create plugin for anonymous voting, I suggest it must be with preventing abuse with email notification. For example. If someone anonymous cliks up voting bottom, then popping up field, there this anonymous user must enter email, then this user entered his email account end validate his voting. ReCaptcha from google is not practical and a bit difficult to guess words
by
Sorry, it is easy to abuse. I have red that to prevent spam it must have limitation per time ( I am thinking 5 in 1 hour).
...