Guest User

Untitled

a guest
Mar 9th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. <?php
  2. // Informacoes do banco e server
  3. $servername = "localhost";
  4. $username="root";
  5. $password="";
  6. $db="hiduo";
  7.  
  8. // Conexao com banco de dados
  9.  
  10. try{
  11. $conn = mysqli_connect($servername, $username,$password,$db);
  12. echo("Conexão efetuada com sucesso!");
  13. }catch(MySQLi_Sql_Exception $ex){
  14. echo("Erro na conexão! ");
  15. }
  16.  
  17. // Selecao dos campos
  18.  
  19. if(isset($_POST['submit'])){
  20. $nome_contato=$_POST['nome_contato'];
  21. $email_contato=$_POST['email_contato'];
  22. $categoria_contato=$_POST['categoria_contato'];
  23. $msg_contato=$_POST['msg_contato'];
  24.  
  25. // Insercao de dados e envio.
  26.  
  27. $msg_query = "INSERT INTO `Suporte`(`nome_contato`, `email_contato`,
  28. `categoria_contato`, `msg_contato`) VALUES ('$nome_contato',
  29. '$email_contato', '$categoria_contato', '$msg_contato')";
  30. try{
  31. $register_result = mysqli_query($conn, $msg_query);
  32. if($register_result){
  33. if(mysqli_affected_rows($conn)>0){
  34. echo("Mensagem enviada com sucesso!");
  35. }else{
  36. echo("Erro no envio da mensagem.");
  37. }
  38.  
  39. }
  40. }catch(Exception $ex){
  41. echo("error".$ex->getMessage());
  42. }
  43. }
  44.  
  45.  
  46. ?>
  47. <!DOCTYPE html>
  48. <html>
  49. <head>
  50. <title> Teste de Suporte </title>
  51. </head>
  52. <body>
  53.  
  54. <form action="suporte.php" method="POST">
  55.  
  56. Nome: <input type="text" name="nome_contato" required="yes"> <br> <br>
  57. Email: <input type="email" name="email_contato" required="yes"> <br> <br>
  58.  
  59. <select name="categoria_contato">
  60. <option name="sugestoes" value="sugestoes"> Sugestões </option>
  61. <option name="reclamacoes" value="reclamacoes"> Reclamações </option>
  62. <option name="bug" value="bug"> Bug </option>
  63. <option name="empresa" value="empresa"> Empresa </option>
  64. </select> <br> <br>
  65.  
  66.  
  67. Mensagem: <textarea rows="4" cols="50" name="msg_contato"
  68. required="yes"> </textarea> <br> <br>
  69. <button type="submit" name="submit" value="submit"> Enviar </button>
  70. </form>
  71. </body>
  72. </html>
Add Comment
Please, Sign In to add comment