So I am new at php and i am trying to send data from my form to phpmyadmin and get it back. Sending part is okay. But everytime i refresh the site, it adds the variables at the last array to where i want to show the variables to user.
It goes on like this: I add a variable from post method. It writes it down. Then i refresh the site. It writes that variable again. At the end. And again.
<?php
$connection = new mysqli($servername,$username,$password,$dbname);
$name_entry=$_POST['item_name'];
$size_entry=$_POST['item_size'];
$entry = "INSERT INTO dbitem(isim,boyut) VALUES('$name_entry','$size_entry')";
$getdata="SELECT * FROM dbitem ORDER BY id";
$datagot=$connection->query($getdata);
if($connection->connect_error){
die("ERROR"); } if($name_entry&&$size_entry&&$connection->query($entry)){}
?>
<form action="VeriDondur.php" method="post">
<p>Eşyanın İsmi:</p>
<input type="text" name='item_name'>
<p>Eşyanın Boyutu:</p>
<input type="text" name='item_size'>
<input type="submit" name="submit" value="Yükle">
</form>
if($datagot->num_rows>0)
{ while($row = $datagot->fetch_assoc())
{ echo $row['isim'] ." ". $row['boyut'] . "n"; }
}
?>
I tried to add $connection->close(); at end of the code but that didnt to anything