我是php和mysql的新手,并且正在创建一个博客网站。当我按下提交按钮时,它没有将数据保存在数据库中。谁能告诉我我的代码出了什么问题。
我的代码是:-
<body>
<div class="card">
<h2>Create New Blog</h2>
<form action="" method="post" enctype="multipart/form-data">
Title: * <input type="text" name="name"><br><br>
Select image to upload:
<input type="file" name="image"/><br><br>
Write about the tilte: *<br><br>
<textarea name="info" rows="5" cols="90"></textarea><br><br>
<input type="submit" value="Submit">
</form>
<?php
include("connect.php");
$dataTime = date("Y-m-d H:i:s");
$rol='A1';
if(isset($_POST['submit'])){
$check = getimagesize($_FILES["image"]["tmp_name"]);
$name = $_POST['name'];
$info = $_POST['info'];
if($check !== false){
$image = $_FILES['image']['tmp_name'];
$imgContent = addslashes(file_get_contents($image));
mysqli_query($db,"INSERT into blogdata(userid, title, image, text, role, created) values ('', '$name', '$imgContent', '$info', '$rol', '$dataTime')");
}
else{
mysqli_query($db,"insert into blogdata(userid, title, image, text, role, created) values ('', '$name', '', '$info', '$rol', '$dataTime')");
}
}
?>
</div>
</body>