-2
Hello there is an error where it does not return to the defined page, but in the url it appears that it enters the page controlProduct that has been defined. The page just turns white.
This is the form.
<form class="" method="post" action="controleProduto.php">
<h1 class="">
<b>Adicione Produtos</b>
</h1>
<div class="form-group">
<label for="nome">
<b>Nome:</b>
</label>
<input type="text" class="form-control" placeholder="Nome do Produto" id="nome" name="nome"> </div>
<div class="form-group">
<label for="valor">
<b>Valor:</b>
</label>
<input type="text" class="form-control" id="valor" name="valor" placeholder="Valor do produto" >
</div>
<button type="submit" class="btn btn-success" name="opcao" id="Cadastrar">Confirmar
</button>
<a href="paginaSessao.php" class="btn btn-light">
<b>Voltar</b>
</a>
</form>
This is the file called after the form." controlProduct".
include 'crudProduto.php';
if(isset($_POST["opcao"])){
$opcao = $_POST["opcao"];
if($opcao=="Cadastrar"){
$nome=$_POST["nome"];
$valor=$_POST["valor"];
cadastraProduto($nome,$valor);
header("Location: paginaInicial.php");
}
else if($opcao=="Alterar"){
$codigo=$_POST["codigo"];
$nome=$_POST["nome"];
$valor=$_POST["valor"];
alterarProduto($codigo, $nome, $valor);
header("Location: visualizarProduto.php");
}
else if($opcao=="Excluir"){
$codigo=$_POST["codigo"];
excluirProduto($codigo);
header("Location: visualizarProduto.php");
}
This is the file that contains the functions. "crudProduct"
include 'conexaoBD.php';
function cadastraProduto($nome,$valor){
conectar();
query("INSERT INTO produto (nome, valor) VALUES('$nome',$valor)");
fechar();
}
I’m new to php. When you say error log, the one that appears on the page? if it is nothing appears
– Igor Vargas
Error log means the file on the server where all errors are recorded. One of the first things a person has to learn to use to develop in PHP.
– Bacco
Anyway, while not sanitizing the strings (and it depends on which DB and library you use, information missing in the question) will give problem.
– Bacco
https://answall.com/questions/3864/70
– Bacco
In case it’s just a college job, but anyway I’m using mysql
– Igor Vargas