本文介绍了我想从表单中的文本中获取值,并在msql中插入表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
首先,我尝试在html中创建表单。
其次,因为我已经拥有了我的数据库和表格。我想将表格中的值插入表格中。但是,它不起作用。
我尝试过:
First, I have tried to create form in html.
Second, as i have already had my database and table. I want to insert the value from form into the table. But, it doesn't work.
What I have tried:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form action="DBMid.php" method="post">
Assignment: <input type="text" name="assignment">
Deadline: <input type="date" name="deadline">
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
// Create connection
$conn = mysqli_connect("127.0.0.1", "root", "", "mymid");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$Assignment = $_POST['assignment'];
$Deadline = $_POST['deadline'];
echo $Assignment;
echo $Deadline;
$sql = "INSERT INTO board (Assignment,Deadline) VALUES ($Assignment, $Deadline)";
mysqli_close($conn);
?>
</body>
</html>
推荐答案
这篇关于我想从表单中的文本中获取值,并在msql中插入表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!