I'm making online voting system. This system has limit for people (population of the area) who can vote (example-10) & then Their votes add to the database. I want to insert values from radio buttons in the database. I tried some code. But it has some error.The vote form data doesn't insert DB & I don't know this is really suitable code for my case. Please If anyone has an idea, please let me know. Thank-you
<html>
<head>
<title>Election</title>
<link rel="stylesheet" href="bootstrap-3.3.4-dist/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/presidential.css" type="text/css">
<link rel="stylesheet" href="css/login.css" type="text/css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
</head>
<body>
<div class="head">
<div class="container-fluid">
<div class="navbar-header">
<b> Online voting System </b>
</div>
<input type="submit" class="btn btn-primary nextBtn btn-lg pull-right" name="submit" value="Cast Your Vote" />
</div>
</div>
<div class="container">
<form name="vote" method="POST" action="">
<div class="one">
<h2><b>Election</b></h2>
<br>
<div class="funkyradio">
<div class="funkyradio-default">
<input type="radio" name="radio" id="radio1" value="radio1" />
<label for="radio1"><b>A Party</b> <div class="img"><img src="img\A.png" height="75.8em" width="50.3em" ></img> </div> </label>
</div>
<div class="funkyradio-default">
<input type="radio" name="radio" id="radio2" value="radio2" />
<label for="radio2"><b>B Party</b><div class="img"><img src="img\B.jpg" height="75.8em" width="50.3em" ></img> </div></label>
</div>
<div class="funkyradio-default">
<input type="radio" name="radio" id="radio3" />
<label for="radio3"><b>C Party</b><div class="img"><img src="img\C.jpg" height="75.8em" width="50.3em" ></img> </div></label>
</div>
<div class="funkyradio-default">
<input type="radio" name="radio" id="radio4" />
<label for="radio4"><b>D Party</b><div class="img"><img src="img\D.jpg" height="75.8em" width="50.3em" ></img> </div></label>
</div>
<div class="funkyradio-default">
<input type="radio" name="radio" id="radio5" />
<label for="radio5"><b>E Party</b><div class="img"><img src="img\E.jpg" height="75.8em" width="50.3em" ></img> </div></label>
</div>
<div class="funkyradio-default">
<input type="radio" name="radio" id="radio6" />
<label for="radio6"><b> F Party</b><div class="img"><img src="img\F.jpg" height="75.8em" width="50.3em" ></img> </div></label>
</div>
</div>
</div>
</form>
</div>
</body>
</html>
<?php
require'database.php';
if (isset($_POST['submit']))
{$radio=$_POST['radio'];
if($radio!="")
{
$query=mysql_query("INSERT INTO `election`(`candidate_name`) VALUES ('$radio')");
if ($query)
{
echo"Cast your vote successfully";
}
else
{
echo"There is a Some Problem in database";
}
}
}
?>
</div>