Stats: 3,192,110 members, 7,946,726 topics. Date: Thursday, 12 September 2024 at 05:37 AM |
Nairaland Forum / Science/Technology / Programming / What Could Be Wrong With This Php Code? (871 Views)
This Php Is About To Make Me Go Nuts. Pls Help / My Php Code Does Not Execute But Displays Code On Browser, / Pls Help Me With This Php Code (2) (3) (4)
(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: Change these lines: if ($_GET['user']==$row["matno"]){ echo 'Voted'; } To: if (isset($_GET['user'])) { if ($_GET['user']==$row["matno"]){ echo 'Voted'; } } 2 Likes |
(1) (Reply)
I Need Someone To Teach Me Python & Django **For a Fee** / Stop Paying For Credit And Mb And Get Them For Free..enter Here / Lasgidi Online Embark On 30 Day SEO Optimization Of Twaddlehq.com
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 38 |