Guest User

Untitled

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