Skip to content

Instantly share code, notes, and snippets.

@DevWellington
Last active February 12, 2023 01:27
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DevWellington/3a04632fc387878ac45f to your computer and use it in GitHub Desktop.
Save DevWellington/3a04632fc387878ac45f to your computer and use it in GitHub Desktop.
<html>
<head>
<meta charset="utf-8">
<title>Cadastro de Funcionários</title>
<link rel="stylesheet" text="text/css" href="estilo.css">
</head>
<body>
<?php
require ("config.php");
?>
<?php
$nome = $_POST['nome'];
$email = $_POST['email'];
$setor = $_POST['setor'];
$cargo = $_POST['cargo'];
$foto = $_POST['foto'];
$sql = "INSERT INTO funcionarios (nome, email, setor, cargo, foto)
VALUES (:nome, :email, :setor, :cargo, :foto)
";
$stmt = $conexao->prepare($sql);
$params = array(
':nome' => $nome,
':email' => $email,
':setor' => $setor,
':cargo' => $cargo,
':foto' => $foto
);
$stmt->execute($params);
echo "<script>
alert('Funcionário cadastrado com sucesso.');
</script>
<meta http-equiv='refresh' content='0, url=funcionarios.php'>
";
?>
</body>
</html>
<meta charset="utf-8">
<?php
$host = "localhost";
$user = "root";
$pass = "";
$banco = "empresa";
$conexao = new mysqli($host,$user,$pass,$banco);
if (mysqli_connect_errno()) {
die('Não foi possível conectar-se ao banco de dados: ' . mysqli_connect_error());
exit();
}
?>
body{
margin: 0;
padding: 0;
outline: none;
font-family: "Arial";
}
.txt{
height: 35px;
width: 250px;
border: none;
border-radius: 5px;
background-color: #EEE;
padding: 4px;
}
table#tab_lista{
height: 250px;
margin: 0 auto;
padding: 10px;
margin-top: 100px;
border-collapse: collapse;
box-shadow: 5px 5px 2.5px #888888;
border:1px solid #000000;
}
table#tab_lista td, tr {
border: 1px solid #CCC;
}
#tab_cadastro{
height: 250px;
margin: 0 auto;
padding: 10px;
margin-top: 200px;
}
input#botao_cad{
width: 100px;
height: 30px;
background-color: #EFEFEF;
border-radius: 4px;
border: 1px solid #CCC;
}
#cor_cabecalho{
background-color: #AAA;
font-weight: bold;
text-align: center;
}
<?php
require ("config.php");
?>
<html>
<head>
<meta charset="utf-8">
<title>Cadastro de Funcionários</title>
<link rel="stylesheet" text="text/css" href="estilo.css">
</head>
<body>
<div id="cadastro">
<form name="signup" method="post" action="cadastro.php">
<table id="tab_cadastro">
<tr>
<td>Nome:</td>
<td><input type="text" name="nome" required placeholder="Nome do funcionário" id="nome" class="txt" /></td>
</tr>
<tr>
<td>E-mail:</td>
<td><input type="text" name="email" required placeholder="E-mail do Funcionário" id="email" class="txt" /></td>
</tr>
<tr>
<td>Setor:</td>
<td><input type="text" name="setor" required placeholder="Setor do Funcionário" id="setor" class="txt" /></td>
</tr>
<tr>
<td>Cargo:</td>
<td><input type="text" name="cargo" required placeholder="Cargo do Funcionário" id="cargo" class="txt" /></td>
</tr>
<tr>
<td>Foto:</td>
<td><input type="text" name="foto" required placeholder="Foto do Funcionário" id="foto" class="txt" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Cadastrar" name="go" id="botao_cad"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
@oluizbs
Copy link

oluizbs commented Feb 12, 2023

Thanks! I managed to solve the error in my code :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment