为什么这段代码不起作用?我有
<script>
//script to retrieve a list from a page and place it inside a div.
</script>
//This is the list on the otherpage.
<select name='timing' id='timing'> Some Options </select>
放置它的div
<html>
<body>
<form method="post" action="insert.php">
<div id="time"></div>
//some more elements and a submit button
</form>
</body>
</html>
提交数据应该转到php页面,将数据插入数据库
<?php
session_start(); //Use this to include session variables
$con=mysqli_connect("localhost","clinic","myclinic","myclinic");// Check connection
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$query = "INSERT INTO appointment(username, doctor, day, time) VALUES('$_SESSION[username]', '$_POST[doctor]', '$_POST[day]', '$_POST[timing]')";
// So on.
问题是表单提交除了放在div中的值之外的所有值 有任何想法吗?我已经坚持了很长时间。
答案 0 :(得分:2)
表格不提交div。
表单提交输入值
将您的div更改为输入
<input type="time" name="time" />
这是HTML5时间输入