这是代码。我不确定我做错了什么。表单正在数据库中提交,但它是空白的。
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link){
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $link);
if(!$db_selected){
die('can not use' . DB_NAME . ': ' . mysql_error());
}
$value = $_POST['hit'];
$value = $_POST['amount'];
$value = $_POST['category'];
$sql = "INSERT INTO hit (hit) VALUES ('$value')";
if(!mysql_query($sql)){
die('Error: ' . mysql_Error());
}
mysql_close();
?>
这是表格
<!DOCTYPE html>
<html>
<head>
<title>Post Hits</title>
<style type="text/css">
table tr > td { text-align: right; }
table tr > td + td { text-align: left; }
</style>
</head>
<body>
<form action="he.php" method="post">
<table>
<tr>
<td>
Hit:
</td>
<td>
<textarea name="hit" rows="3"></textarea>
</td>
</tr>
<tr>
<td>
amount:
</td>
<td>
<input type="text" id = "amount" name="amount" />
</td>
</tr>
<tr>
<td>
category:
</td>
<td>
<select name="category" id="category">
<option value="">- Choose -</option>
<option value="Blue">survey</option>
<option value="Green">batch</option>
<option value="Orange">misc</option>
<option value="Red">masters</option>
<option value="Yellow">qual</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center;">
<input type="submit" id="submit" value="Submit!" />
</td>
</tr>
</table>
</form>
</body>
</html>
我对这一切还是很陌生,所以无论我犯了什么错误,对我来说都不明显。谢谢