Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost" ;
- $username = "root" ;
- $password = "" ;
- $dbname = "pap" ;
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $instrucao = $conn->prepare("INSERT INTO tickets(problema, eletrecidade, agua, assunto, info) VALUES(?,?,?,?,?)");
- if($instrucao == FALSE){
- echo "<p>ERRO: dados não inseridos!</p>";
- }
- else{
- $instrucao->bind_param("sssss", $_POST["problema"], $_POST["eletrecidade"], $_POST["agua"], $_POST["assunto"], $_POST["info"]);
- $resultado = $instrucao->execute();
- if($resultado == TRUE){
- echo "<p>Dados inseridos.</p>";
- }
- else{
- echo "<p>ERRO: dados não inseridos!</p>";
- }
- }
- $conn->close();
- ?>
- <form name="registodados" method="POST" action="submit.php">
- <fieldset>
- <!-- Escolher problema geral -->
- <label>Problema Geral</label>
- <select name="prob" id="prob">
- <option disabled selected hidden>Escolha uma opção...</option>
- <option value="luz">Luz</option>
- <option value="agua">Agua</option>
- <option value="elevador">Elevador</option>
- </select>
- <!-- Escolher problemas eletrecidade -->
- <label>Eletrecidade</label>
- <select name="eletrecidade" id="eletrecidade">
- <option disabled selected hidden>Escolha uma opção...</option>
- <option value="curto circuito">Não há luz</option>
- <option value="curto circuito">Curto circuito</option>
- </select>
- <!--Escolher problemas agua -->
- <label>Agua</label>
- <select name="agua" id="agua">
- <option disabled selected hidden>Escolha uma opção...</option>
- <option value="Nao ha agua">Não há água</option>
- <option value="Inundacao">Inundação</option>
- </select>
- <label for="assunto">Assunto:</label>
- <input type="text" name="assunto" id="assunto" maxlength=100 placeholder="Assunto">
- </fieldset>
- <fieldset>
- <label for="info">Info:</label>
- <textarea type="text" name="info" id="info" maxlength=50 placeholder="Descrição detalhada"></textarea>
- </fieldset>
- <div>
- <input type="reset" value="Limpar">
- <input type="submit" value="Submeter">
- </div>
- </form>
- CREATE TABLE `tickets` (
- `problema` varchar(30) NOT NULL,
- `eletrecidade` varchar(30) NOT NULL,
- `agua` varchar(30) NOT NULL,
- `assunto` varchar(30) NOT NULL,
- `info` varchar(30) NOT NULL
- ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement