【发布时间】:2011-03-13 00:45:08
【问题描述】:
我有以下代码:
<html><body>
<?php
$con = mysql_connect("localhost","will","blahblah");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("blahblah", $con);
$sql="INSERT INTO links (link, notes, username)
VALUES
('$_POST[link]','$_POST[notes]','$_POST[username]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 link added";
mysql_close($con)
?>
</body></html>
它应该在我的数据库中插入一个链接、注释和一个用户名,但它没有。我不知道为什么,希望能得到一些帮助!它从下面的表格中获取这些值:
<div id="stylized" class="myform">
<form id="form" name="form" method="post" action="user.php">
<label>Username
<span class="small">Enter Your Username</span>
</label>
<input type="text" name="name" id="username" />
<label>Link
<span class="small">Paste Your Link</span>
</label>
<input type="text" name="email" id="link" />
<label>Notes
<span class="small">Add Some Notes</span>
</label>
<input type="text" name="password" id="notes" />
<button type="submit"></button>
<div class="spacer"></div>
</form>
</div>
谢谢!
【问题讨论】:
-
您遇到什么错误? (顺便说一句,用户名输入是“名称”而不是“用户名”)
-
错误说明了什么?
-
没有错误只是没有插入...
标签: php mysql html database forms