Unable to change field in php when id is not 1

Asked

Viewed 29 times

1

Good evening, I’m trying to make a change to my database through php, but when clicking on "change" it only allows if the code is equal to 1, I have already put in html to send the id as soon as we click on "change" but it only pulls the page if the code is equal to 1, follows below my code:

<?php
session_start();
$id = $_SESSION['id'];
$nome = $_SESSION['usuario'];
$idfornec = $_GET['idfornec'];

?>

<?php

$host = "localhost";
$user = "root";
$senha = "";
$banco = "visaosystem";
$conexao = mysqli_connect($host, $user, $senha) or die (mysql_error());
mysqli_select_db($conexao, $banco) or die (mysql_error());

$selectfornec = ("SELECT fornecedor.razaosocial, fornecedor.nomefantasia, fornecedor.cnpj, fornecedor.ie, fornecedor.ativo, contatofornec.telefone1, contatofornec.telefone2, 
contatofornec.celular, contatofornec.email, enderecofornec.cep, enderecofornec.logradouro, enderecofornec.bairro, enderecofornec.municipio, enderecofornec.cidade, enderecofornec.uf, enderecofornec.numero, enderecofornec.complemento FROM fornecedor
INNER JOIN contatofornec ON (fornecedor.idfornec = contatofornec.idcontatofornec) INNER JOIN enderecofornec ON (fornecedor.idfornec = enderecofornec.idenderecofornec) WHERE fornecedor.idfornec = '$idfornec'") or die(mysqli_error());


$dadosfornec = $conexao->query($selectfornec);


        while ($linha = $dadosfornec->fetch_assoc()) {
        $razaosocial = $linha["razaosocial"];
        $nomefantasia = $linha["nomefantasia"];
        $cnpj = $linha["cnpj"];
        $ie = $linha["ie"];
        $ativo = $linha["ativo"];
        $primeironum = $linha["telefone1"];
        $segundonu = $linha["telefone2"];
        $celular = $linha["celular"];
        $email = $linha["email"];
        $cep = $linha["cep"];
        $endereco = $linha["logradouro"];
        $bairro = $linha["bairro"];
        $municipio = $linha["municipio"];
        $cidade = $linha["cidade"];
        $uf = $linha["uf"];
        $numero = $linha["numero"];
        $complemento = $linha["complemento"];
?>
  • 1

    The error could be in this $idFornec, just print it out.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.