₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,083 members, 8,420,223 topics. Date: Thursday, 04 June 2026 at 01:58 PM

Toggle theme

What Could Be Wrong With This Php Code? - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingWhat Could Be Wrong With This Php Code? (933 Views)

1 Reply

What Could Be Wrong With This Php Code? by Nobody: 12:31pm On Oct 02, 2015
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>';
}


}


?>
Re: What Could Be Wrong With This Php Code? by kenomobola(m): 5:02pm On Oct 02, 2015
JoelAmawhe:
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>';
}


}


?>
Change these lines:
if ($_GET['user']==$row["matno"]){
echo 'Voted';
}

To:
if (isset($_GET['user'])) {
if ($_GET['user']==$row["matno"]){
echo 'Voted';
}
}
1 Reply

This Php Is About To Make Me Go Nuts. Pls HelpMy Php Code Does Not Execute But Displays Code On Browser,Pls Help Me With This Php Code234

Pacific School SoftwareCustomized mobile App join Group.Pls Help: