Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. <?php
  2. $servername = "localhost" ;
  3. $username = "root" ;
  4. $password = "" ;
  5. $dbname = "pap" ;
  6.  
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. // Check connection
  10. if ($conn->connect_error) {
  11. die("Connection failed: " . $conn->connect_error);
  12. }
  13.  
  14. $instrucao = $conn->prepare("INSERT INTO tickets(problema, eletrecidade, agua, assunto, info) VALUES(?,?,?,?,?)");
  15. if($instrucao == FALSE){
  16. echo "<p>ERRO: dados não inseridos!</p>";
  17. }
  18. else{
  19. $instrucao->bind_param("sssss", $_POST["problema"], $_POST["eletrecidade"], $_POST["agua"], $_POST["assunto"], $_POST["info"]);
  20. $resultado = $instrucao->execute();
  21. if($resultado == TRUE){
  22. echo "<p>Dados inseridos.</p>";
  23. }
  24. else{
  25. echo "<p>ERRO: dados não inseridos!</p>";
  26. }
  27. }
  28. $conn->close();
  29. ?>
  30.  
  31. <form name="registodados" method="POST" action="submit.php">
  32. <fieldset>
  33. <!-- Escolher problema geral -->
  34. <label>Problema Geral</label>
  35. <select name="prob" id="prob">
  36. <option disabled selected hidden>Escolha uma opção...</option>
  37. <option value="luz">Luz</option>
  38. <option value="agua">Agua</option>
  39. <option value="elevador">Elevador</option>
  40.  
  41. </select>
  42.  
  43. <!-- Escolher problemas eletrecidade -->
  44. <label>Eletrecidade</label>
  45. <select name="eletrecidade" id="eletrecidade">
  46. <option disabled selected hidden>Escolha uma opção...</option>
  47. <option value="curto circuito">Não há luz</option>
  48. <option value="curto circuito">Curto circuito</option>
  49.  
  50. </select>
  51.  
  52.  
  53. <!--Escolher problemas agua -->
  54. <label>Agua</label>
  55. <select name="agua" id="agua">
  56. <option disabled selected hidden>Escolha uma opção...</option>
  57. <option value="Nao ha agua">Não há água</option>
  58. <option value="Inundacao">Inundação</option>
  59.  
  60.  
  61.  
  62. </select>
  63. <label for="assunto">Assunto:</label>
  64. <input type="text" name="assunto" id="assunto" maxlength=100 placeholder="Assunto">
  65. </fieldset>
  66. <fieldset>
  67. <label for="info">Info:</label>
  68. <textarea type="text" name="info" id="info" maxlength=50 placeholder="Descrição detalhada"></textarea>
  69. </fieldset>
  70. <div>
  71. <input type="reset" value="Limpar">
  72. <input type="submit" value="Submeter">
  73. </div>
  74. </form>
  75.  
  76. CREATE TABLE `tickets` (
  77. `problema` varchar(30) NOT NULL,
  78. `eletrecidade` varchar(30) NOT NULL,
  79. `agua` varchar(30) NOT NULL,
  80. `assunto` varchar(30) NOT NULL,
  81. `info` varchar(30) NOT NULL
  82. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement