Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'db/conexa.php';
- ini_set('display_errors', true);
- error_reporting(E_ALL);
- # INICIO - ATUALIZAR USUARIO
- if(isset($_POST['atualizar'])){
- $id = (int)$_GET['id'];
- $nome = (string)$_POST['nome'];
- $senha = (string)$_POST['senha'];
- $email = (string)$_POST['email'];
- $sqlUpdate = 'SELECT usuarios SET nome = :nome, senha = :senha, email = :email where id = :id';
- try {
- $update = $db->prepare($sqlUpdate);
- $update->bindValue('id', $id, PDO::PARAM_INT);
- $update->bindValue('nome', $nome, PDO::PARAM_STR);
- $update->bindValue('senha', $senha, PDO::PARAM_STR);
- $update->bindValue('email', $email, PDO::PARAM_STR);
- if($update->execute()){
- header('Location: http://localhost:8080/PHP/Wood/home.php');
- }
- } catch (Exception $e) {
- echo 'Erro ao atualizar'. $e->getMessage();;
- }
- }
- #FIM - ATUALIZAR USUARIO
- # INICIO - PEGAR USUARIO
- $id = (int)$_GET['id'];
- $sql = 'SELECT * FROM usuarios where id = :id';
- try {
- $select = $db->prepare($sql);
- $select->bindValue(':id', $id, PDO::PARAM_INT);
- $select->execute();
- }
- catch (Exception $e) {
- echo $e->getMessage();
- }
- $result = $select->fetch(PDO::FETCH_OBJ);
- # FIM - ATUALIZAR USUARIO
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Hoo</title>
- <!-- Compiled and minified CSS -->
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.8/css/materialize.min.css">
- <!-- Compiled and minified JavaScript -->
- <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.8/js/materialize.min.js"></script>
- </head>
- <body>
- <div class="row">
- <form class="col s12" method="POST">
- <div class="row">
- <div class="input-field col s6">
- <input type="text" name="nome" class="validate" value="<?php echo $result->nome; ?>">
- <label></label>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="input-field col s6">
- <input name="senha" type="password" class="validate" value="<?php echo $result->senha ?>">
- <label></label>
- </div>
- </div>
- <div class="row">
- <div class="input-field col s6">
- <input name="email" type="email" class="validate" value="<?php echo $result->email ?>">
- <label></label>
- <center><button class="btn waves-effect waves-light" type="submit" name="'atualizar'">Atualizar
- <i class="material-icons right"></i></center>
- </button>
- </div>
- </div>
- </div>
- </div>
- </form>
- </div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment