我正在学习自己编写代码。
这是我的代码尝试将图书信息添加到我的数据库中。结果是:导入已完成!但是我的数据库没有任何东西。请帮我!非常感谢。
这是我的代码:
<?php
ini_set('default_charset', 'utf-8');
$server_username = "root";
$server_password = "";
$server_host = "localhost";
$database = 'book';
$conn = mysqli_connect($server_host,$server_username,$server_password,$database)
or die("Failed to connect database!");
if (isset($_POST["btn_submit"])) {
$bookname = $_POST["bookname"];
$author = $_POST["author"];
$orgname = $_POST["orgname"];
$orglink = $_POST["orglink"];
$intro = $_POST["intro"];
$categories = $_POST["categories"];
$sql = "INSERT INTO info(bookname, author, orgname, orglink, intro, categories)
VALUES ( '$bookname', '$author', '$orgname', '$orglink', '$intro', '$categories')";
mysqli_query($conn,$sql);
echo "Import completed!";
}
else {
echo "Failed to Import book!";
}
$conn->close();
?>