Guest User

Untitled

a guest
Nov 2nd, 2018
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.65 KB | None | 0 0
  1. <php
  2. class Banco{
  3. private $host;
  4. private $user;
  5. private $password;
  6. private $database;
  7. private $status;
  8.  
  9. public function __construct(){
  10. $this->Conectar();
  11. }
  12. private function conectar(){
  13. $this->host = "localhost";
  14. $this->user = "root";
  15. $this->password = "";
  16. $this->database = "projetoaplicado";
  17.  
  18. $db = mysqli_connect($this->host,$this->user,$this->password,$this->database);
  19.  
  20. if ($db)
  21. {
  22. if (mysqli_select_db($db, $this->database))
  23. {$this->status = true;}
  24. else {
  25. $this->status = false;}
  26. }
  27. else {
  28. $this->status = false;
  29. }
  30. }
  31. public function StatusConexao(){
  32. return $this->status;
  33. }
  34. }
  35. ?>
  36.  
  37. <?php
  38.  
  39. class Gestante {
  40. public $id;
  41. public $nome;
  42. public $idade;
  43. public $rendabrutafamiliar;
  44. public $auxiliofinanceiro;
  45. public $escolaridade;
  46. public $ocupacao;
  47. public $apoiofamiliar;
  48. public $telefone;
  49. public $regiao;
  50.  
  51. public function _construct($i="",$nom="",$ida="",$ren="",$aux="",$esc="",$ocu="",$apo="",$tel="",$reg=""){
  52. $this->id = $i;
  53. $this->nome = $nom;
  54. $this->idade = $ida;
  55. $this->rendabrutafamiliar = $ren;
  56. $this->auxiliofinanceiro = $aux;
  57. $this->escolaridade = $esc;
  58. $this->ocupacao = $ocu;
  59. $this->apoiofamiliar = $apo;
  60. $this->telefone = $tel;
  61. $this->regiao = $reg;
  62. }
  63.  
  64. public function insere(){
  65.  
  66. $con=mysqli_connect("localhost","root","","projetoaplicado");
  67.  
  68. $sql = "INSERT INTO gestante (id, nome, idade, rendabrutafamiliar, auxiliofinanceiro, escolaridade, ocupacao, apoiofamiliar, telefone, regiao)
  69. VALUES ('".$this->nome."','".$this->idade."','".$this->rendabrutafamiliar."','".$this->auxiliofinanceiro."','".$this->escolaridade."','".$this->ocupacao."','".$this->apoiofamiliar."','".$this->telefone."','".$this->regiao."')";
  70. $resultado = mysqli_query($sql);
  71. return $resultado;
  72. }
  73. }
  74. ?>
  75.  
  76. <?php
  77. include("banco.php");
  78. include("classGestante.php");
  79.  
  80. $bd = new Banco();
  81. $varpost=filter_input_array(INPUT_POST, FILTER_DEFAULT);
  82. if (isset ($varpost['acao']))
  83. {
  84. $gestante = new
  85. Gestante($varpost['nome'],$varpost['idade'],$varpost['rendabrutafamiliar'],
  86. $varpost['auxiliofinanceiro'],$varpost['escolaridade'],$varpost['ocupacao'],
  87. $varpost['apoiofamiliar'],$varpost['telefone'],$varpost['regiao']);
  88. $resultado = $gestante->insere();
  89. if ($resultado) {
  90. $msg = "Gestante cadastrada com sucesso";
  91. } else {
  92. $msg = "Falha ao cadastrar cliente";
  93. }
  94. }
  95. ?>
  96.  
  97. <!DOCTYPE html>
  98.  
  99. <html>
  100. <head>
  101. <meta charset="UTF-8">
  102. <title>Questionário Cadastral</title>
  103. </head>
  104. <body>
  105. <form method="POST">
  106. <h1 align="center">Dados Pessoais</h1>
  107.  
  108. <table border="10" align="center">
  109. <tr>
  110. <td>
  111. <label>Nome:</label>
  112. <input type="text" size="40" name="nome" required>
  113. </td>
  114. </tr>
  115. <tr>
  116. <td>
  117. <label>Idade:</label>
  118. <input type="number" min="0" name="idade" required>
  119. </td>
  120. </tr>
  121. <tr>
  122. <td>
  123. <label>Renda Bruta Familiar (em salários mínimos):</label>
  124. <input type="radio" name="rendabrutafamiliar" value="1-" required>Menos de 1
  125. <input type="radio" name="rendabrutafamiliar" value="1+">Mais de 1
  126. <input type="radio" name="rendabrutafamiliar" value="2+">Mais de 2
  127. <input type="radio" name="rendabrutafamiliar" value="2+">Mais de 3
  128. <input type="radio" name="rendabrutafamiliar" value="3+">Mais de 4
  129. <input type="radio" name="rendabrutafamiliar" value="5+">Mais de 5
  130. </td>
  131. </tr>
  132. <tr>
  133. <td>
  134. <label>Auxílio financeiro do governo:</label>
  135. <input type="radio" name="auxiliofinanceiro" value="sim" required>Sim
  136. <input type="radio" name="auxiliofinanceiro" value="nao">Não
  137. </td>
  138. </tr>
  139. <tr>
  140. <td>
  141. <label>Escolaridade:</label>
  142. <input type="radio" name="escolaridade" value="fundamental completo" required>Fundamental Completo
  143. <input type="radio" name="escolaridade" value="fundamental incompleto">Fundamental Incompleto
  144. <input type="radio" name="escolaridade" value="medio completo">Médio Completo
  145. <input type="radio" name="escolaridade" value="medio incompleto">Médio Incompleto
  146. <input type="radio" name="escolaridade" value="curso tecnico">Curso Técnico
  147. <input type="radio" name="escolaridade" value="nao informado">Não Informado
  148. </td>
  149. </tr>
  150. <tr>
  151. <td>
  152. <label>Ocupação:</label>
  153. <input type="radio" name="ocupacao" value="estudante" required>Estudante
  154. <input type="radio" name="ocupacao" value="menor aprendiz">Menor Aprendiz
  155. <input type="radio" name="ocupacao" value="trabalho informal">Trabalho Informal
  156. <input type="radio" name="ocupacao" value="nenhum">Nenhum
  157. </td>
  158. </tr>
  159. <tr>
  160. <td>
  161. <label>Presença de apoio familiar:</label>
  162. <input type="radio" name="apoiofamiliar" value="sim" required>Sim
  163. <input type="radio" name="apoiofamiliar" value="nao">Não
  164. </td>
  165. </tr>
  166. <tr>
  167. <td>
  168. <label>Telefone:</label>
  169. <input type="text" name="telefone" maxlength="11" placeholder="DDD + Telefone" pattern="[0-9]{11}" required>
  170. </td>
  171. </tr>
  172. <tr>
  173. <td>
  174. <label>Região:</label>
  175. <input type="radio" name="regiao" value="barreiro" required>Barreiro
  176. <input type="radio" name="regiao" value="centrosul">Centro-Sul
  177. <input type="radio" name="regiao" value="leste">Leste
  178. <input type="radio" name="regiao" value="nordeste">Nordeste
  179. <input type="radio" name="regiao" value="noroeste">Noroeste
  180. <input type="radio" name="regiao" value="norte">Norte
  181. <input type="radio" name="regiao" value="oeste">Oeste
  182. <input type="radio" name="regiao" value="pampulha">Pampulha
  183. <input type="radio" name="regiao" value="vendanova">Venda Nova
  184. </td>
  185. </tr>
  186. </table>
  187. <center>
  188. <input type="submit" name="acao" value="Cadastrar">
  189. </center>
  190. </form>
  191. </body>
Add Comment
Please, Sign In to add comment