After using a form and submit button to take user input, I want my page to print out the values from a database, however, after hitting submit the new page has nothing at all. even the h is not printed.
<html>
<body>
<?php
echo "h";
$server = "localhost";
$username = "root";
$pass = "fghjkl";
$db = "world";
$conn = new mysqli($server, $username, $pass,$db) or die("Connect failed: %s\n". $conn -> error);
$select = "select Name,Continent,Region from country where name like 'a%'";
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$country =$_POST["country"];
$continent = $_POST["continent"];
$region =$_POST["region"];
$add = "insert into Country(name,continent,region) values (". $country.",".$continent.","$region.")";
$conn->query($add);
$result = $conn->query($select);
if ($result->num_rows > 0) {
echo "l";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "name: " . $row["Name"]. " - continent: " . $row["Continent"]. " - in - " . $row["Region"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>
</body>
</html>
The form is :
<html>
<body>
<form name = "test" action="hlo.php" method="POST">
country: <input type="text" name="country"><br>
continent: <input type="text" name="continent"><br>
region: <input type="text" name = "region"><br>
<input type="submit" name = "submit" value="submit">
</form>
</body>
</html>