I'm trying to figure out why I can't update my votes in database with my radio buttons. I'm not really good in coding but I'm trying my best to figure out but I'm out of luck now.
<!doctype html>
<html>
<head>
<title>vote3</title>
</head>
<body>
<?php
$users_account = $_GET['users_account'];
$connect = mysqli_connect('localhost', 'root', 'password','surveytest');
$query = "SELECT * FROM users_account WHERE username='archievald'";
$q = mysqli_query($connect, $query);
while($row = mysqli_fetch_array($q)) {
$id = $row[0];
$username = $row[1];
$password = $row[2];
$voted = $row[3];
$acc_type = $row[4];
echo "<h1>Is he good in english?</h1>";
?>
<table>
<form action="" method="POST">
<?php
$questions = "SELECT * FROM questions WHERE pollid='test'";
$q2 = mysqli_query($connect, $questions);
while($r = mysqli_fetch_array($q2)) {
$questions = $r[1];
$votes = $r[2];
$newvotes = $votes + 1;
$ip = $_SERVER['REMOTE_ADDR'];
echo '<tr><td>'.$questions.'</td><td> <input type="radio" name="polloption" value="'.$questions.'" </td></tr>';
}
if (isset($_POST['vote'])) {
$polloption = $_POST['polloption'];
if ($polloption == "") {
die("You didnt select an option.");
} else {
mysqli_query($connect, "UPDATE questions SET votes = $newvotes WHERE questions='$polloption'");
die("You voted successfully");
}
}
}
?>
<tr><td><input type="submit" name="vote" value="votes" /></td></tr>
</form>
</table>
</body>
</html>
as far as I remember the main problem is in here
mysqli_query($connect, "UPDATE questions SET votes = $newvotes WHERE questions='$polloption'");
die("You voted successfully");