Delete Contact Information in PHP/MySQL Using PDO

Delete Contact Information

We already did in the tutorial for Insert Contact Information and Update Contact Information. So, I decided to create a follow-up tutorial for Delete Contact Information. We're gonna use Delete Statement to delete data from our database table. This is our data. Result

Delete - PHP Query Using PDO

  1. <?php
  2. require_once('db.php');
  3.  
  4. $get_id=$_GET['tbl_member_id'];
  5.  
  6. // sql to delete a record
  7. $sql = "Delete from tbl_member where tbl_member_id = '$get_id'";
  8.  
  9. // use exec() because no results are returned
  10. $conn->exec($sql);
  11. header('location:index.php');
  12. ?>

Delete Button

  1. <a href="delete_contact.php<?php echo '?tbl_member_id='.$id; ?>">
  2. <button type="submit" class="btn_confirm" onclick="return confirm(' Delete Contact ( <?php echo $first_name?> ) ? ');">
  3. Delete
  4. </button>
  5. </a>

Output:

Deleting Data. ResultAfter Deleting Data. Result Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at rolyn02@gmail.com. Practice Coding. Thank you very much.

Add new comment