Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function cadastrarUsuario($usuario){
- $pdo = conectar();
- $sql = "insert into usuarios(nome) values (?)";
- $cadastrar = $pdo->prepare($sql);
- $cadastrar->bindValue(1, $usuario);
- $cadastrar->execute();
- return $pdo->lastInsertId();
- }
- if(isset($_POST['cadastrar'])){
- $usuario = $_POST['nome'];
- $novoUsuario = cadastrarUsuario($usuario);
- }
- ?>
- <!DOCTYPE HTML>
- <html lang="pt-br">
- <head>
- <meta charset="utf-8"/>
- <!--<link href="estilo/estilo.css" rel="stylesheet"/>-->
- <title>Aplicando meus conhecimentos!</title>
- </head>
- <body>
- <table>
- <thead>
- <th>Nome</th>
- <th>E-Mail</th>
- <th>Editar</th>
- <th>Deletar</th>
- </thead>
- <tbody>
- <?php $usuarios = listar(); ?>
- <?php foreach ($usuarios as $usuario): ?>
- <tr>
- <td><?php echo $usuario->nome; ?></td>
- <td><?php echo $usuario->email; ?></td>
- <td><a href="editar">Editar</a></td>
- <td><a href="deletar">Deletar</a></td>
- </tr>
- <?php endforeach; ?>
- </tbody>
- </table>
- <form method="post" action="">
- <input type="hidden" name="cadastrar"/>
- <label>Email:</label>
- <input type="text" maxlength="50" size="20" name="email"/><br/>
- <label>Nome:</label>
- <input type="text" maxlength="50" size="20" name="nome"/><br/>
- <label>Senha:</label>
- <input type="text" maxlength="16" size="16" name="senha"/><br/>
- <button type="submit">Cadastrar</button>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment