我已经阅读了这块板上的每条评论 4 小时,以解决此代码的问题。我希望有人可以在这里向菜鸟提供一些反馈。
<?php
//Join.php
define('DB_NAME', 'biblaunch');
define('DB_USER', 'xxxxxxx');
define('DB_PASSWORD', 'xxxxxxxxx');
define('DB_HOST', 'xxxxxxxxx.hostedresource.com');
$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\'t use ' . DB_NAME . ': ' . mysql_error());
}
$value = $_POST['name'];
$value2 = $_POST['email'];
$value3 = $_POST['shirt'];
$sql = "INSERT INTO customer (name, email, shirt) VALUES ('$value',
'$value2','$value3')";`
$result = mysql_query($sql);
mysql_close();
?>
我的 HTTP/mainpage 使用这种表单结构:
<form id="joinForm" action="join.php" method="post" accept-charset="utf-8">
<fieldset>
<div class="row-fluid">
<div class="span12">
<label class="no">Name</label>
<input name="name" placeholder="Name" type="text">
</div>
</div>
<div class="row-fluid">
<div class="span12">
<label class="no">Email</label>
<input name="email" placeholder="Email" type="text">
</div>
</div>
<div class="row-fluid">
<div class="span12">
<div class="row-fluid">
<select style="display: none;" name="shirt" class="selectpicker span12">
<option selected="selected">Select Preferred Shirt</option>
<option>Mens Style Shirt</option>
<option>Ladies Style Shirt</option>
<option>Youth/Child Shirt</option>
</select>
</div>
</div>
</div>
<div class="formFoot">
<button type="submit" class="btn">Submit</button>
提前感谢您的所有帮助