Ciao a tutti, sto creando un sistema di votazioni, dove un utente può appunto votare i commenti di altri utenti. Tutti i commenti sono dentro una tabella, e per ogni riga c'è un tasto submit che dovrebbe aggiungere un voto al commento di quella riga. In ogni caso non riesco a capire come far funzionare il pulsante submit dentro l'echo allacciandolo alla funzione $POST. Lo script è questo:
Codice PHP:
<?php$con=mysqli_connect("localhost","nome_utente","pass","database");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM commenti_utenti where id_post = '$id_post'");
echo "<table class='CSSTableGenerator'>
<tr>
<td WIDTH ='50px'>Nickname</td>
<td WIDTH ='130px'>Commento</td>
<td WIDTH ='50px'>Tot. Voti</td>
<td WIDTH ='50px'>Vota</td>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td WIDTH ='40px' >" . $row['nickname'] . "</td>";
echo "<td height ='10px' >" . $row['commento'] . "</td>";
echo "<td >" . $row['voti_tot'] . "</td>";
echo "<td ><input name=\"button3\" type=\"submit\" value=\"Vota\" class=\"button3\" /></td>";
echo "</tr>";
}
echo "</table>";
if(isset($_POST['button3'])){
echo "<br><p style='text-align: center;'><span style='font-size: medium; font-family: tahoma; color: red;'> Grazie per il tuo voto. </span></p> </br>";
echo ("<script>location='http://www.miosito.it/votazioni/';</script>");
return;
}
mysqli_close($con);?>
Spero che qualche anima pia possa aiutarmi a capire cosa c'è di sbagliato, quando clicco su Vota non succede nulla