Guest User

Untitled

a guest
Oct 11th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. <?php while($dado = $con->fetch_array()) {?>
  2.  
  3. <?php
  4.  
  5. if(!empty($_FILES['uploaded_file'])){
  6. $username = 'root';
  7. $password = '';
  8. $connection = new PDO( 'mysql:host=localhost;dbname=nise', $username );
  9.  
  10. $query = "INSERT INTO resposta_denuncia (descricao_resposta, imagem, id_usuario)
  11. VALUES (:descricao_resposta, :imagem, :id_usuario)";
  12.  
  13. $statement = $connection->prepare($query);
  14.  
  15. $path = "img_denuncia/";
  16. $path = $path . basename( $_FILES['uploaded_file']['name']);
  17. if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $path))
  18.  
  19. $valores = array();
  20. $valores[':descricao_resposta'] = $_POST['descricao_resposta'];
  21. $valores[':imagem'] = $_FILES['uploaded_file']['name'];
  22. $valores[':id_usuario'] = 2;
  23.  
  24. if( $result = $statement->execute($valores))
  25. {
  26. echo 1; // dados enviados com sucesso
  27.  
  28. }
  29. else
  30. {
  31. // na verdade o else não é necessário mas se preferir pode colocar
  32. echo 0; // erro ao tentar enviar dados
  33. }
  34.  
  35. if($connection->connect_errno)
  36. echo"Falha na conexão:(".$connection->connect_errno.")".$connection->connect_error;
  37.  
  38. $consulta = "SELECT id, data, descricao, imagem FROM denuncia ";
  39. $con = $connection->query($consulta) or die ($connection->error);
  40.  
  41. }
  42. ?>
  43.  
  44. <div class="card mb-3">
  45. <div id="wrapper">
  46. <div id="content-wrapper">
  47. <div class="container-fluid">
  48. <div class="card-body">
  49. <div class="table-responsive">
  50. <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
  51.  
  52. <thead>
  53. <tr>
  54. <th id="id_bd">Nº</th>
  55. <th id="date">Data e hora</th>
  56. <th id="local">Local</th>
  57. <th id="comentario">Comentário</th>
  58. <th id="imagem">Imagem</th>
  59. </tr>
  60. </thead>
  61.  
  62. <?php while($dado = $con->fetch_array()) {?>
  63. <tr>
  64. <td><?ph echo $dado["id"];?> </td>
  65. <td><?ph echo $dado["data"];?> </td>
  66. <td><?ph echo $dado["descricao"];?> </td>
  67. <td><?ph echo $dado["imagem"];?> </td>
  68. </tr>
  69. <?php }?>
  70.  
  71. </table>
  72. </div>
  73. </div>
  74. <div class="card-footer small text-muted">Atualizado ontem às 11:59 PM</div>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
Add Comment
Please, Sign In to add comment