Hi,
I'm trying to make a rating system, but I don't want people to vote more than once. Can I limit one vote per IP address for each specific ID?
here's my code.
<?php
ob_start();
include 'connect.php';
$id = $_GET['id'];
// submit
if ($_POST['submit'])
{
//get data
$id_post = $_POST['id'];
$rating_post = $_POST['rating'];
if ($rating_post <=5&&$rating_post >0)
{
$get = mysql_query("SELECT * FROM photographs WHERE id='$id_post'");
$get = mysql_fetch_assoc($get);
$get = $get['rating'];
if ($get==0)
$newrating = $get + $rating_post;
else
$newrating = ($get + $rating_post)/2;
$update = mysql_query("UPDATE photographs SET rating='$newrating' WHERE id='$id_post'");
}
header("Location: index.php");
}
?>
<form action="rate.php" method="POST">
Choose Rating:
<br>
<select name="rating">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="submit" name="submit" value="Rate!">
</form>