Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. public function update(){
  2.  
  3. try{
  4.  
  5. $stmt = $this->conn->prepare("UPDATE Tabela SET Dado1 = :Dado1, Dado2 = :Dado2, Dado3 = :Dado3 WHERE DadoId = :DadoId");
  6. $stmt->bindParam(':Dado1', $Dado1, PDO::PARAM_STR);
  7. $stmt->bindParam(':Dado2', $Dado2, PDO::PARAM_STR);
  8. $stmt->bindParam(':Dado3', $Dado3, PDO::PARAM_STR);
  9. $stmt->execute();
  10.  
  11. if ($stmt > 0)
  12. {
  13.  
  14. header ( "location:retorno.php" );
  15.  
  16. }
  17.  
  18. return $stmt;
  19.  
  20. }catch (PDOStatement $excption){
  21.  
  22. header("Location: ./error.php?err=Unable to insert");
  23. echo 'Erro: '.$exception->getMessage();
  24. return null;
  25.  
  26. }
  27. }
  28.  
  29. $up = new Classe();
  30.  
  31. if($_SERVER['REQUEST_METHOD']=='POST'){
  32.  
  33. if(isset($_POST['btn-update']))
  34. {
  35. $stDado1= strip_tags($_POST['stn-Dado1']);
  36. $stDado2 = strip_tags($_POST['stn-Dado2']);
  37. $stDado3 = strip_tags($_POST['stn-Dado3']);
  38. $sendInsert = $up->update($stDado1, $stDado2, $stDado3);
  39. }
  40.  
  41. exit();
  42. }
  43.  
  44. <form method="POST">
  45. <div class="form-group">
  46. <label>Dado 1</label>
  47. <input class="form-control" name="dado1" type="text" >
  48. </div>
  49. <div class="form-group">
  50. <label>Dado 2</label>
  51. <input class="form-control" name="dado2" type="text">
  52. </div>
  53. <div class="form-group">
  54. <label>Dado 3</label>
  55. <hr>
  56. <div name="dado3" contentEditable="false">
  57. </div>
  58. </div>
  59. <hr>
  60. <a class="btn btn-warning edit">Editar</a>
  61. <a class="btn btn-warning cancel">Cancelar</a>
  62. <button type="submit" name="btn-update" class="btn btn-danger ">Salvar</button>
  63.  
  64. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement