Guest User

Tutorial City

a guest
Feb 13th, 2010
2,628
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.     include_once('config.php');
  4.  
  5.     if(isset($_POST['submit'])){
  6.        
  7.         $nome  = $_POST['nome'];
  8.         $email = $_POST['email'];
  9.         $id    = $_POST['id'];
  10.        
  11.         $sql  = ' UPDATE usuario SET nome = ? , email = ? WHERE id = ? ';
  12.        
  13.         try {
  14.             $query = $bd->prepare($sql);
  15.             $query->execute(Array($nome,$email,$id));
  16.         } catch (PDOException $e) {
  17.             echo $e->getMessage();
  18.         }      
  19.     }
  20.  
  21. ?>
  22.  
  23. <!DOCTYPE HTML>
  24. <html lang="en-US">
  25. <head>
  26.     <title>Update</title>
  27.     <meta charset="UTF-8">
  28. </head>
  29. <body>
  30.     <h1>Update</h1>
  31.    
  32.     <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
  33.    
  34.         <div><label for="nome">Nome</label><input type="text" name="nome" value="eduardo" /></div>
  35.         <div><label for="email">Email</label><input type="text" name="email" value="eduardo.matos@tutorial-city.net" /></div>
  36.         <input type="hidden" name="id" value="1" />
  37.         <input type="submit" value="Atualizar" name="submit" />
  38.     </form>
  39.    
  40. </body>
  41. </html>
RAW Paste Data