Dante0704

Untitled

Jan 31st, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. <?php
  2. function cadastrarUsuario($usuario){
  3. $pdo = conectar();
  4. $sql = "insert into usuarios(nome) values (?)";
  5. $cadastrar = $pdo->prepare($sql);
  6. $cadastrar->bindValue(1, $usuario);
  7. $cadastrar->execute();
  8. return $pdo->lastInsertId();
  9. }
  10.  
  11. if(isset($_POST['cadastrar'])){
  12. $usuario = $_POST['nome'];
  13. $novoUsuario = cadastrarUsuario($usuario);
  14. }
  15. ?>
  16.  
  17. <!DOCTYPE HTML>
  18. <html lang="pt-br">
  19. <head>
  20. <meta charset="utf-8"/>
  21. <!--<link href="estilo/estilo.css" rel="stylesheet"/>-->
  22. <title>Aplicando meus conhecimentos!</title>
  23. </head>
  24. <body>
  25. <table>
  26. <thead>
  27. <th>Nome</th>
  28. <th>E-Mail</th>
  29. <th>Editar</th>
  30. <th>Deletar</th>
  31. </thead>
  32. <tbody>
  33. <?php $usuarios = listar(); ?>
  34. <?php foreach ($usuarios as $usuario): ?>
  35. <tr>
  36. <td><?php echo $usuario->nome; ?></td>
  37. <td><?php echo $usuario->email; ?></td>
  38. <td><a href="editar">Editar</a></td>
  39. <td><a href="deletar">Deletar</a></td>
  40. </tr>
  41. <?php endforeach; ?>
  42. </tbody>
  43. </table>
  44. <form method="post" action="">
  45. <input type="hidden" name="cadastrar"/>
  46. <label>Email:</label>
  47. <input type="text" maxlength="50" size="20" name="email"/><br/>
  48. <label>Nome:</label>
  49. <input type="text" maxlength="50" size="20" name="nome"/><br/>
  50. <label>Senha:</label>
  51. <input type="text" maxlength="16" size="16" name="senha"/><br/>
  52. <button type="submit">Cadastrar</button>
  53. </form>
  54. </body>
  55. </html>
Advertisement
Add Comment
Please, Sign In to add comment