Hello,
I have a website where users submit anonymous messages, which are automatically posted publically on a rolling list. I am trying to implement a community flagging/voting system so users can eliminate spam messages themselves. I would like a flag icon to pop up next to each submission, and for entries to be deleted from the database (or at least not displayed) after 3 user flags.
Here's what I have so far:
First, as I loop through all of the past entries and echo them onto the page, I also echo a form for each entry:
while(($row2=mysql_fetch_array($result2, MYSQL_ASSOC)) and ($row=mysql_fetch_array($result, MYSQL_ASSOC)))
{
echo "<p>", htmlspecialchars($row['secret']), "<hr></p>"; //This is the entry
echo "<div ID='flag'><form name='spam' method='post'><input type='submit' name='", $row2['time'], "' value='Flag' /></form></div>"; // This is the form for each entry
}
Every form has the same name (spam), and each form has a single input whose name is the time value of when the entry was first submitted. I just used this to create a unique form input for each entry. This part works fine. Then when someone clicks on the submit for a given entry, it is supposed to add 1 to the "spam" column of the given row. Here is my code:
if(isset($_POST[$row2['time']]))
{
$query3 = "SELECT spam FROM secret WHERE time = {$row2['time']}";
$result3 = mysql_query($query3);
$new = $result3++;
$update = "Update secret SET spam=$new";
mysql_query($update);
}
This isn't working properly. When I click one of the submit buttons, the spam column does not increment for any of the rows. I think this is wrong: (isset($_POST[$row2['time']])).
I'm really new to PHP and I know my coding is pretty sloppy, but I would appreciate any help. Thanks in advance.