Share Pastebin
Guest
Public paste!

Tutorial City

By: a guest | Feb 13th, 2010 | Syntax: PHP | Size: 0.72 KB | Hits: 770 | Expires: Never
This paste has a previous version, view the difference. Copy text to clipboard
  1. <?php
  2.  
  3.         include_once('config.php');
  4.  
  5.         if(isset($_POST['submit'])){
  6.                
  7.                 $id   = $_POST['id'];
  8.                 $sql  = ' DELETE FROM usuario WHERE id = ? ';
  9.                
  10.                 try {
  11.                         $query = $bd->prepare($sql);
  12.                         $query->bindParam(1,$id,PDO::PARAM_INT);
  13.                         $query->execute();
  14.                         echo 'usuario deletado!';
  15.                 } catch (PDOException $e) {
  16.                         echo $e->getMessage();
  17.                 }              
  18.         }
  19.  
  20. ?>
  21.  
  22. <!DOCTYPE HTML>
  23. <html lang="en-US">
  24. <head>
  25.         <title>Delete</title>
  26.         <meta charset="UTF-8">
  27. </head>
  28. <body>
  29.         <h1>Delete</h1>
  30.        
  31.         <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
  32.        
  33.                 <div><label for="id">ID</label><input type="text" name="id" /></div>
  34.                 <input type="submit" value="Deletar" name="submit" />
  35.         </form>
  36.        
  37. </body>
  38. </html>