Advertisement
hercioneto

confirmaExclusaoDados.php

Sep 21st, 2023 (edited)
1,053
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.34 KB | None | 0 0
  1. <!Doctype html>
  2. <html lang="pt-br">
  3. <head>
  4.     <meta charset="utf-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1">
  6.     <meta name="Author" content="Hercio Neto">
  7.     <title>Aula HTML - Formulários</title>
  8.  
  9.     <style type="text/css">
  10.         body {
  11.             font-family: Arial, sans-serif;
  12.             font-size: 16px;
  13.             background-color: #f0f0f0;
  14.         }
  15.         .container {
  16.             max-width: 800px;
  17.             margin: 0 auto;
  18.             padding: 20px;
  19.             background-color: #fff;
  20.             box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
  21.         }
  22.         form label {
  23.             display: block;
  24.             margin-bottom: 5px;
  25.             font-weight: bold;
  26.  
  27.         }
  28.         form input[type="text"], form input[type="email"], form select {
  29.  
  30.             width: 98%;
  31.              
  32.             padding: 10px;
  33.              
  34.             border: 1px solid #ccc;
  35.              
  36.             border-radius: 4px;
  37.              
  38.             margin-bottom: 20px;
  39.  
  40.         }
  41.  
  42.         form input[type="submit"] {
  43.  
  44.         background-color: #4CAF50;
  45.          
  46.         color: #fff;
  47.          
  48.         padding: 10px 20px;
  49.          
  50.         border: none;
  51.          
  52.         border-radius: 4px;
  53.          
  54.         cursor: pointer;
  55.          
  56.         }
  57.  
  58.         form input[type="submit"]:hover {
  59.  
  60.         background-color: #3e8e41;
  61.          
  62.         }
  63.  
  64.  
  65.         @media screen and (max-width: 480px) {
  66.  
  67.         form input[type="text"], form input[type="email"], form select {
  68.  
  69.             width: 90%;
  70.              
  71.         }
  72.  
  73.         form input[type="submit"] {
  74.  
  75.         width: 90%;
  76.          
  77.         }
  78.  
  79.         }
  80.  
  81.     </style>
  82.    
  83. </head>
  84.  
  85. <body>
  86.  
  87.     <div class="container">
  88.  
  89.     <h1>Cadastro de Pessoa</h1>
  90.    
  91.     <?php
  92.  
  93.     // Verificar se o formulário foi submetido
  94.     if ($_SERVER["REQUEST_METHOD"] == "POST") {
  95.         if (isset($_POST['codigo'])) {
  96.            
  97.        
  98.      ?>
  99.         <label for="codigo">Excluindo código:</label>
  100.         <?php
  101.         $codigo = $_POST['codigo'];
  102.         echo $codigo;  ?>  
  103.  
  104.         <?php
  105.  
  106.     $conexao = new mysqli("localhost", "root", "", "uri_web");
  107.  
  108.     // Verificar se a conexão foi estabelecida corretamente
  109.     if ($conexao->connect_error) {
  110.         die("Erro na conexão: " . $conexao->connect_error);
  111.     }
  112.  
  113.     $sql = "DELETE FROM pessoas WHERE `pessoas`.`codigo` = $codigo";
  114.    
  115.     $resultado_pagina = $conexao->query($sql);
  116.         if ($resultado_pagina=="true"){
  117.             echo "<br><h3>Dados excluídos com sucesso</h3>";
  118.         } else {
  119.             echo "Dados não excluídos, tente novamente.";
  120.         }
  121.     }
  122.     } else {   
  123.         echo "Preencha o formulário";
  124.     }
  125. ?>
  126.         <p><a href="index.php">Voltar</a></p>
  127.        
  128.     </form>
  129.  
  130.     </div>
  131.    
  132. </body>
  133.  
  134. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement