-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenviar_exercicio_bd.php
More file actions
38 lines (31 loc) · 1.43 KB
/
enviar_exercicio_bd.php
File metadata and controls
38 lines (31 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
ini_set("display_errors", "on");
//usar estilo CSS na pág. PHP
echo '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="custom_style.css" />';
require("./db_connect.php");
//verifica se a sessão está iniciada
require('./sessao.php');
//verificar se o input=submit foi usado = variavel $_POST['submit'] existe
if (isset($_POST['submit'])){
//apenas efetuando o login com conta de admin é possivel enviar dados
if ($tipo_conta == 2){
/*Funcao usada p/ criar string valida em SQL usada por um "statment" de SQL.
The string is encoded to an escaped SQL string, taking in account the current character set of the connection*/
$nomeExercicio = mysqli_real_escape_string($db_connect, $_POST['nomeExercicio']);
$tipo = mysqli_real_escape_string($db_connect, $_POST['tipo']);
$sql = "INSERT INTO rinte.exercico (nomeExercicio, tipo)
VALUES ('$nomeExercicio', '$tipo')";
$query = mysqli_query($db_connect, $sql);
if ($query) {
echo 'Exercício ' . $nomeExercicio.', inserido com sucesso.<br><a href = "perfil_admin.php">Regressar ao Perfil</a>';
}
else {
echo 'Exercício ' . $nomeExercicio.', não inserido. <br><a href = "perfil_admin.php">Regressar ao Perfil</a>';
}
}
}
else {
echo 'Erro na submissão do formulário. <br><a href = "perfil_admin.php">Regressar ao Perfil</a>';
}
mysqli_close($db_connect);
?>