i'm doing a voting system. After displaying all candidates from my DB, a user is to click on a candidate's image to vote. I am trying to use GET to get the matric number of a candidate so as to echo a text. The Error is this: Upon loading the page, an error message comes up even without clicking on any image as follows-
Notice: Undefined index: user in C:\xampp\htdocs\projects\onlinevoting\vote.php on line 74
Voted
What could be wrong?
if (isset($_POST['display'])) {
$position_selected = $_POST['position_selected'];
$sql = "SELECT * FROM candidate WHERE position='$position_selected'";
$run_query = mysqli_query($db_conn, $sql);
if (mysqli_num_rows($run_query) > 0) {
$nr = mysqli_num_rows($run_query);
echo '<h3 style="font-size:2em;text-align:center">('.$nr.') ASPIRANTS FOR <span style="color:maroon;text-decoration:underline"> '.$position_selected.'</span></h3>';
while ($row = mysqli_fetch_array($run_query)) {
echo '<div class="asp">
<a class="votelink" href="?user='.$row["matno"].'"><img title="Click Image to Vote" height="300" width="300" src="data:image;base64,'.$row[6].' "></a><br><p style="font-weight:bolder;font-size:1.5em;width:300px;text-align:center;margin-bottom:0px;">'.$row[1].'<br><b><p style="font-size:1em;font-weight:bold;width:300px;text-align:center;margin-bottom:0px;">'.$row[2].'/'.$row[3].'</p><b><br>
</div>';
}
if ($_GET['user'] == $row["matno"]) {
echo 'Voted';
}
} else {
echo '<p style="color:darkred;font-weight:bolder;font-size:1.6em;text-align:center;">No candidate for this Position</p>';
}
}
?>