Don't like ads? PRO users don't see any ads ;-)
Guest

Tutorial City

By: a guest on Feb 13th, 2010  |  syntax: PHP  |  size: 0.93 KB  |  hits: 1,910  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3.         include_once('config.php');
  4.  
  5.         if(isset($_POST['submit'])){
  6.                
  7.                 $nome  = $_POST['nome'];
  8.                 $email = $_POST['email'];
  9.                
  10.                 $sql  = ' INSERT INTO usuario(id,nome,email,criado_em) VALUES (NULL,:nome,:email,NOW()) ';
  11.                
  12.                 try {
  13.                         $query = $bd->prepare($sql);
  14.                         $query->bindValue(':email',$email,PDO::PARAM_STR);
  15.                         $query->bindValue(':nome',$nome,PDO::PARAM_STR);
  16.                         $query->execute();
  17.                 } catch (PDOException $e) {
  18.                         echo $e->getMessage();
  19.                 }              
  20.                
  21.         }
  22.  
  23. ?>
  24.  
  25.  
  26. <!DOCTYPE HTML>
  27. <html lang="en-US">
  28. <head>
  29.         <title>Create</title>
  30.         <meta charset="iso-8859-1">
  31. </head>
  32. <body>
  33.         <h1>Create</h1>
  34.        
  35.         <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
  36.                 <div><label for="nome">Nome</label><input type="text" name="nome" /></div>
  37.                 <div><label for="email">Email</label><input type="text" name="email" /></div>
  38.                 <div><input type="submit" value="criar usuário!" name="submit" /></div>
  39.         </form>
  40. </body>
  41. </html>