-2
Good afternoon guys, on my site has the products section
When I register a product it does not appear but when I register another it appears
Example> when I register the product Vinicius he doesn’t show up then I register another product called test, hence the product Vinicius begins to appear and the product test does not appear
<div class="container">
<div class="row">
<?php
include_once("conect.php");
$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_STRING);
$result_usuario = "SELECT * FROM produ_usu WHERE id = '$id'";
$resultado_usuario = mysqli_query($conn, $result_usuario);
$row_usuario = mysqli_fetch_assoc($resultado_usuario);
if(($resultado_usuario) AND ($resultado_usuario->num_rows != 0)){
?>
<?php
while($row_usuario = mysqli_fetch_assoc($resultado_usuario)){
?>
<div class="col-sm-4">
<div class="block-q">
<h3>Nome do Produto: <?php echo $row_usuario['produto2']; ?></h3>
<hr>
<p>Email do Cadastro: <?php echo $row_usuario['email']; ?></p>
<p>ID do Cadastro: <?php echo $row_usuario['id_primary']; ?></p>
<p>ID do Usuário: <?php echo $row_usuario['id']; ?></p>
<a href="envia-orcamento.php?id_primary=<?php echo $row_usuario['id_primary']; ?>" class="btn btn-primary">Enviar Orçamento</a>
</div>
</div>
<?php
}?>
<?php
}else{
echo "<div class='alert alert-danger' role='alert'>Nenhum orçamento cadastrado!</div>";
}
?>
</div>
</div>
this is my code showing the products registered by user
This is my code that registers the product in the database
<?php
session_start();
include_once("conexao.php");
$nome2 = filter_input(INPUT_POST, 'nome2', FILTER_SANITIZE_STRING);
$telefone2 = filter_input(INPUT_POST, 'telefone2', FILTER_SANITIZE_STRING);
$produto2 = filter_input(INPUT_POST, 'produto2', FILTER_SANITIZE_STRING);
$id = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_STRING);
$email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL);
//echo "senha: $senha <br>";
//echo "E-mail: $email <br>";
$result_usuario = "INSERT INTO produ_usu (nome2, telefone2, produto2, id, email, created) VALUES ('$nome2', '$telefone2', '$produto2', '$id', '$email', NOW())";
$resultado_usuario = mysqli_query($conn, $result_usuario);
if(mysqli_insert_id($conn)){
$_SESSION['msg'] = "<p style='color:green;'>Usuário cadastrado com sucesso</p>";
header("Location: sucess.php");
}else{
$_SESSION['msg'] = "<p style='color:red;'>Usuário não foi cadastrado com sucesso</p>";
header("Location: sucess.php");
}
Thanks in advance!!!
Right, you register and then go to sucess.php. On the page that has the SELECT from which comes the variable $id that is in the clause WHERE id = '$id'"
– user60252
Not the successful page is just a warning the error is happening on another page
– Otimiza Mais
I know this, the first sentence of my comment is a statement. The question is of the second sentence, that is, On the page that has the SELECT from which comes the variable $id that is in the clause WHERE id = '$id'"
– user60252
Dude I don’t understand I’m new at this I’m 15 years old and I started programming, could you please explain to me
– Otimiza Mais
How do you access that first page of the question? which is the link?
– user60252
http://localhost/ESQUINA-DAS-TINTAS/Adm/clients/client.php? id=20
– Otimiza Mais
I get it, let’s assume you’re registering Vinicius, then go to the page to check, is the Vinicius id 20? after the registration you saw there in the bank his id?
– user60252
It’s not right the id is 20 even
– Otimiza Mais
with regard to this everything is ok
– Otimiza Mais
I believe the id on the select page is the previous id
– user60252
I don’t think because he registers that id because then I register another product and the product that I registered in the past appears
– Otimiza Mais
And the new one doesn’t appear
– Otimiza Mais
I will create an environment here on my server
– user60252
Blz, vlw mutio guy thanks really
– Otimiza Mais
who is this id_primary ?
– user60252
This Primary id is the product id
– Otimiza Mais
and user ID and id
– Otimiza Mais
and how id_primary is inserted in the table
– user60252
he is an INT a Primary key
– Otimiza Mais
id_primary = AUTO_INCREMENT
– Otimiza Mais
have you tried commenting this line $row_usuario = mysqli_fetch_assoc($resultado_usuario); just below $resultado_usuario
– user60252
Do not add a comment to your question or an answer to say "Thank you". Comments are intended to ask for clarification, leave constructive criticism or add more relevant but brief information - not to socialize. If you wish to say "thank you", vote for or accept that person’s reply. See how https://i.stack.Imgur.com/evLUR.png
– user60252