0
Everyone all right? I’ve searched the entire forum and even other forums and couldn’t find answers on this. If anyone can take a look and point out my mistake I’d appreciate.
Follow the form:
<form action="add.php" method="post" name="form1">
div> <table class='table table-hover table-responsive table-bordered' style="background-color:white;">
<tr>
<td>Data de Cadastro:</td>
<td></td>
</tr>
<tr>
<td>Nome Fantasia:</td>
<td><input type="text" name="nomefantasia" required autofocus class='form-control'/>
</tr>
<tr>
<td>Razão Social</td>
<td><input type="text" name="razaosocial" required class='form-control'/><td>
</tr>
<tr>
<td>CNPJ:</td>
<td><input type="text" name="cnpj" required class='form-control'/></td>
</tr>
<tr>
<td>Inscrição Estadual:</td>
<td><input type="text" name="inscricaoestadual" required class='form-control'/></td>
</tr>
<tr>
<td>Categoria:</td>
<td><select name="categoria" size="1">
<option>Selecione...</option>
<?PHP mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('suinos') or die(mysql_error());
mysqli_set_charset($mysqli,"utf8");
?>
<?php $query = mysql_query("SELECT categoria_id, categoria_titulo FROM comp_categoria");
while($categoria = mysql_fetch_array($query)) { ?>
<option class='form-control' value="<?php echo $categoria['categoria_id'] ?>"><?php echo $categoria['categoria_titulo'] ?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td>Endereço:</td>
<td><input type="text" name="endereco" required class='form-control'/></td>
</tr>
<tr>
<td>Número:</td>
<td><input type="text" name="numero" required class='form-control'/></td>
</tr>
<tr>
<td>Bairro:</td>
<td><input type="text" name="bairro" required class='form-control'/></td>
</tr>
<td>CEP:</td>
<td><input type="text" name="cep" required class='form-control'/>
</td>
</tr>
<tr>
<td>Cidade:</td>
<td>
<select name= "cidade"><option>Escolha a cidade</option>
<?php $queryy = mysql_query("SELECT Id, Nome FROM comp_cidade ORDER BY Nome ASC");
while($cidade = mysql_fetch_array($queryy)) { ?>
<option class='form-control' value="<?php echo $cidade['Id'] ?>"><?php echo $cidade['Nome'] ?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td> Estado:</td>
<td><select name="estado" size="1">
<option>Selecione...</option>
<?php $bquery = mysql_query("SELECT Id, Nome FROM comp_estado ORDER BY Nome ASC");
while($estado = mysql_fetch_array($bquery)) { ?>
<option class='form-control' value="<?php echo $estado['Id'] ?>"><?php echo $estado['Nome'] ?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td>E-mail:</td>
<td><input type="email" name="email" required class='form-control'/></td>
</tr>
<tr>
<td>Contato:</td>
<td><input type="text" name="contato" required class='form-control'/></td>
</tr>
<tr>
<td>Telefone:</td>
<td><input type="text" name="fone" required class='form-control'/>
</td>
</tr>
<tr>
<td> Nome do Banco:</td>
<td><select name="banco">
<option>Selecione...</option>
<?php $bquery = mysql_query("SELECT id_banco, nomebanco FROM fat_bancos");
while($nbanco = mysql_fetch_array($bquery)) { ?>
<option class='form-control' value="<?php echo $nbanco['id_banco'] ?>"><?php echo $nbanco['nomebanco'] ?></option>
<?php } ?>
</select></td>
</tr>
<tr>
<td>Número da conta</td>
<td><input type="text" name="nconta" required class='form-control'/></td>
</tr>
<tr>
<td>Número da Agencia:</td>
<td><input type="text" name="nagencia" required class='form-control'/></td>
</tr>
<td>
<center>
<input type="Submit" name="Submit" value="Salvar" class="btn btn-primary">
</center>
</td>
</tr>
<tr>
<td>
</tr>
</table>
</div>
</form>
And here PHP with Insert:
<?php
include($_SERVER['DOCUMENT_ROOT']."/NovoModelo/config.php");
if(isset($_POST['Submit'])) {
$nomefantasia = mysqli_real_escape_string($mysqli, trim($_POST['nomefantasia']));
$razaosocial = mysqli_real_escape_string($mysqli, trim($_POST['razaosocial']));
$endereco = mysqli_real_escape_string($mysqli, trim($_POST['endereco']));
$numero = mysqli_real_escape_string($mysqli, trim($_POST['numero']));
$bairro = mysqli_real_escape_string($mysqli, trim($_POST['bairro']));
$idcidade = $_POST['cidade'];
$idestado = $_POST['estado'];
$email = mysqli_real_escape_string($mysqli, trim($_POST['email']));
$contato = mysqli_real_escape_string($mysqli, trim($_POST['contato']));
$fone = mysqli_real_escape_string($mysqli, trim($_POST['fone']));
$cnpj = mysqli_real_escape_string($mysqli, trim($_POST['cnpj']));
$cep = mysqli_real_escape_string($mysqli, trim($_POST['cep']));
$inscricaoestadual = mysqli_real_escape_string($mysqli, trim($_POST['inscricaoestadual']));
$nbanco = mysqli_real_escape_string($mysqli, trim($_POST['banco']));
$nconta = mysqli_real_escape_string($mysqli, trim($_POST['nconta']));
$nagencia = mysqli_real_escape_string($mysqli, trim($_POST['nagencia']));
$categoria = $_POST['categoria'];
$result = mysqli_query($mysqli, "INSERT INTO comp_fornecedor(FORN_ID, FORN_NOMEFANTASIA, FORN_RAZAOSOCIAL, FORN_ENDERECO, FORN_NUMERO, FORN_BAIRRO, FORN_IDCIDADE, FORN_IDESTADO, FORN_EMAIL, FORN_CONTATO, FORN_FONE, FORN_CNPJ, FORN_CEP,FORN_INSCRICAOESTADUAL, FORN_CATEGORIAID, FORN_IDBANCO,FORN_NCONTA,FORN_NAGENCIA)
VALUES('','$nomefantasia', '$razaosocial', '$endereco','$numero', '$bairro', '$idcidade', '$idestado', '$email', '$contato', '$fone','$cnpj','$cep','$inscricaoestadual','$categoria','$nbanco','$nconta', '$nagencia')") or die(mysqli_error($mysqli));
}
?>
Thank you in advance!
it is on an external page. In which I am calling on include.
– J.C. Ferri
"or die(mysqli_error))" I put to present error and still nothing.
– J.C. Ferri
In Insert it would not be
...or die (mysql_error())
? Is only(mysql_error)
– Laércio Lopes
fixed or die (mysql_error()). Still, nothing yet.
– J.C. Ferri
note that the variable $razaosocial has to be wrapped in simple quotes like the others.
– user60252
Boy, I created a bank just to test this and it’s working perfectly. Can you edit your question and put all the code fixed?
– user60252