By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,918 Members | 1,557 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,918 IT Pros & Developers. It's quick & easy.

Deleting database entrys from a website

P: 1
Hello, I am trying to delete entries from my database via a website with a button and at the moment it is deleting entries without the click of the button

Expand|Select|Wrap|Line Numbers
  1.           <?php
  2.           if(isset($_POST['submit']))
  3.           {
  4.         echo "Delet button pressed";
  5. $con = mysql_connect("localhost","blah","blah");
  6. if (!$con)
  7.   {
  8.   die('Could not connect: ' . mysql_error());
  9.   }
  10.  
  11. mysql_select_db("cfarmer_comp4", $con);
  12.  
  13. mysql_query("DELETE FROM Requests WHERE ListenerName = 'steve' ");
  14.  
  15. mysql_close($con);
  16. }
  17. ?> 
  18.  
  19.  
  20.  
  21.  
  22.  
  23.       </p>
please please please help
Apr 8 '11 #1
Share this Question
Share on Google+
1 Reply


JKing
Expert 100+
P: 1,206
Hello. Without seeing the HTML this is only a guess.

My assumption is that you have a submit button named "submit".

Submit buttons use the value parameter for their text. Therefore $_POST['submit'] is always set and your function executes on every page load.

But that is just a guess, please provide the HTML that goes along with your code.
Apr 8 '11 #2

Post your reply

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