Israel

Israel

  • 707
  • 1.3k
  • 217.7k

Good codes but its doesnt show datas inserted

Dec 9 2019 10:59 AM
Hi,
 
As a new PHP programer I am testing to insert datas into my database. Every things are showing me that the codes are well. For example I test the connection to my database it's fine:
I am using PHP 7.3.10 on Windows 10
 
testconnection.php
 

$conn = new mysqli("localhost", "root", "", "login");

if ($conn->connect_error) {

die("ERROR: Unable to connect: " . $conn->connect_error);

}

echo 'Connected to the database.
';

$result = $conn->query("SELECT * FROM usuario");

echo "Number of rows: $result->num_rows";

$result->close();

$conn->close();

?>

//I receive this message:

Connected to the database.
Number of rows: 2
 
 

Inserttodb.php

$link=mysqli_connect("localhost","root","");
mysqli_select_db($link,"phpmysqli");

?>

if(isset($_POST["submit"]))

{

mysqli_query($link,"insert into table1 values('$_POST[t1]','$_POST[t2]')");

}

?>

 When I insert data ist doesnt show any error. But when I check in phpMysql there is nothing. Ouuuf, I passed days to resolv this. But nothing!!!