选择表单中的标签不起作用

时间:2014-07-08 19:46:17

标签: html sql forms html-select

我有一个表单和一个下拉列表......

<form method="post" action="rew1.php" id="inputform">
<select form="inputform" name="some1">
<option value="" disabled="disabled" selected="selected">Select Travel Mode</option>
<option value="Train">Train</option>
<option value="Flight">Flight</option>
</select>
</form>

但是当我发布使用此表格时,价值火车或航班没有张贴到数据库.... 这是服务器端代码......

<?php
$con=mysqli_connect("127.0.0.1","root","plsdonthack","cab");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$sql="INSERT INTO cabs (NAME,IDNO,HOSTEL,MODE,DATE,TIME,TFNO,CONTACT)
VALUES
('$_POST[name]','$_POST[idno]','$_POST[hostel]','$_POST[mode]','$_POST[date]','$_POST[time]','$_POST[tfno]','$_POST[contact]')";



if (!mysqli_query($con,$sql))
  {
  die('Error: ' . mysqli_error($con));
  }

mysqli_close($con);
header("location:http://localhost\overflow\index.html");
?>

我犯的错误是什么??

1 个答案:

答案 0 :(得分:3)

您应该为select设置名称属性,如下所示:

 <select name="something">