Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php
  2. # Access session.
  3. session_start() ;
  4.  
  5. if ( !isset( $_SESSION[ 'user_id' ] ) ) { require ( 'login_tools.php' ) ; load() ; }
  6.  
  7. # Connect to the database.
  8. require ('connect_db.php');
  9.  
  10. // Attempt delete query execution
  11. $stmt = $dbc->prepare("DELETE FROM users WHERE user_id = ? ");   // prepare query with placeholder (?) for id value
  12. $stmt->bind_param('i', $_SESSION['user_id']);                    // bind the id value to the placeholder
  13.  
  14. if ($stmt->execute()) {                                          // execute the query
  15.     echo "Records were deleted successfully.";
  16.     } else {
  17.     echo "ERROR: Not able to execute query " ;
  18.     }
  19. # Close database connection.
  20. mysqli_close( $dbc ) ;
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement