I don't understand why isset function doesn't work here:
include 'db.php';
if(isset($_POST['Submit'])) {
$name = $_POST['title'];
$text = $_POST['text'];
$category = $_POST['category'];
$insert = mysqli_query($con,
"INSERT INTO `items`(
`title`,
`text`,
`category`
)
VALUES (
'$name',
'$text',
'$category')"
);
if (!$insert) {
echo mysqli_error($con);
} else {
echo "Inserted!";
}
}
<form method="post">
<input type="text" name="title" placeholder="Enter the title..">
<input type="text" name="text" placeholder="Enter the text..">
<input type="text" name="category" placeholder="Enter the category..">
<input type="submit" value="Submit">
</form>
The database is not updated. Without that,my code is ok,but it's not what I want.
您的输入提交没有名称属性
<input type="submit" value="Submit" name="Submit">
您需要使用名称属性,名称属性的文本应与isset($ _ POST ['submit'])相匹配
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.