473,511 Members | 17,577 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

undefined index error

20 New Member
This is going to sound really stupid, but I cannot figure out why I am getting this error.

Expand|Select|Wrap|Line Numbers
  1. Undefined index: bil in C:\wamp\www\FORM\deleteadmin.php on line 4
  2.  
  3. Undefined index: adminID in C:\wamp\www\FORM\deleteadmin.php on line 5

line 4 and 5 looks like this,

Expand|Select|Wrap|Line Numbers
  1. $bil = $_POST['bil'];
  2. $adminID = $_POST['adminID'];
the full code are new.php which links to the deleteadmin.php that contains the error.

new.php
Expand|Select|Wrap|Line Numbers
  1. echo "<form name='update $bil' method=post action=newuser.php>" ?>
  2.     <tr>
  3.         <td><center><?php echo $bil; ?></center></td>
  4.         <td><?php echo $row['name']; ?></td>
  5.         <td><?php echo $row['tel']; ?></td>
  6.         <td><?php echo $row['email']; ?></td>
  7.         <td><?php echo $row['username']; ?></td>
  8.         <td><?php echo $row['password']; ?></td>
  9.         <td><a href = "deleteadmin.php"><img src="img/deleteicon.png" align="center"></a></td>
  10.         <input type=hidden value={$row['adminID']} name=adminID>
  11.         <input type=hidden value=$bil name=bil>
  12.     </tr>
  13. <?php 
  14.     echo "</form>";
  15. }
  16. ?>

deleteadmin.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include ('config.php');
  3.  
  4. $bil = $_POST['bil'];
  5. $adminID = $_POST['adminID'];
  6.  
  7. $result = mysql_query("DELETE FROM `admin` WHERE `adminID`= '$adminID'") or die (mysql_error());
  8.  
  9. if($result)
  10. {
  11. ?>
  12. <script language="javascript">
  13. alert("User No : <?php echo "$bil"; ?> DELETED");
  14. location.href="new.php";
  15. </script>
  16.  
  17. <?php
  18. }
  19. else
  20. {
  21. ?>
  22.  
  23. <script language="javascript">
  24. alert("User No : <?php echo "$bil"; ?> NOT DELETED");
  25. location.href="new.php";
  26. </script>
  27. <?php
  28. }
  29. ?>
What do I need to do to fix them?
I don't understand why this is happening, and I'd love to know how to make it go away.
Apr 1 '14 #1
5 1296
Dormilich
8,658 Recognized Expert Moderator Expert
the problem is that you have a link and not a submit button. you can simply combine button and image like:

Expand|Select|Wrap|Line Numbers
  1. <button type="submit">
  2.     <img src="…">
  3. </button>
Apr 1 '14 #2
leesyaa
20 New Member
I figured this do the trick!

Expand|Select|Wrap|Line Numbers
  1. <td><a href = "deleteadmin.php?adminID=<?php echo $row['adminID']; ?>&bil=<?php echo $bil; ?>"><img src="img/deleteicon.png" align="center"></a></td>
Apr 2 '14 #3
Dormilich
8,658 Recognized Expert Moderator Expert
well, if you‘re fine with using GET instead of POST … (and the fact that GET requests get cached)
Apr 2 '14 #4
leesyaa
20 New Member
less secure? hmm maybe this :D

Expand|Select|Wrap|Line Numbers
  1. $sql = "DELETE FROM admin WHERE md5(adminID)= '".md5($adminID)."'";
Apr 2 '14 #5
Dormilich
8,658 Recognized Expert Moderator Expert
that doesn‘t change the fact that both values are plainly visible on transmission. when they are on your server, they have reached the "secure" spot.
Apr 2 '14 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1765
by: shalini11 | last post by:
Hello, I am using a page that has a dropdown list. when the user selects an item from the list and click on submit button, it opens a new page and displays the selected item. I've used as method...
6
20839
by: jsgoodrich | last post by:
I am looking for some help if anyone can lend a hand. I have a simple php website that displays a table from my mysql database. To prep for my MCSE I moved my home server to Windows 2003...
7
2523
by: Philth | last post by:
Hey there, it has to be said that I am a complete novice in PHP, I know this is a common error and has probably been covered to some degree already - but my head really does hurt - so I couldn't...
1
1616
by: jason1987 | last post by:
I keep getting the undefined index error on the bottom two rows of my code simparent and equtype - the other two work fine yet there is no difference in my code. equtypeid is even from the same table...
6
1624
by: nadomt | last post by:
Happy friday to all! I am getting the below error when visiting my user filter page. i have gone to line 68, but cant see what the problem is...can anyone assist? advanced THANK YOU! Error:...
3
3312
by: furqi | last post by:
hi i am actually having problem in this code i am trying to check the value in the if condition in the very last lines of the code but i am facing an error of "undefined index" can anybody tell me so...
0
891
by: Antonio Bacasno | last post by:
Please help me, I keep getting "Undefined Index Error". I'm also a noob in PHP. I can't echo back my equipcode and adddata, though I can successfully echo back curloc. Curloc and equipcode are...
0
1610
by: Antonio Bacasno | last post by:
I'm creating a page where I will create an account for authorized users. But I always get into this Undefined Index error. There are only two variables, but I can't seem to find what is wrong? Could...
1
1674
by: umarsulur | last post by:
Undefined index for the last element of array while fetching datas from db through an array variable. I use for each loop to seperate and also in_array()...kindly help pls..... Here is the...
2
2519
by: yateesh | last post by:
This is the code to display the details (postfunction.php) <?php // Connection data (server_address, database, username, password) $dbhost = 'localhost'; $dbname = 'posting'; $dbuser =...
0
7245
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7144
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7427
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5671
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
449
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.