【发布时间】:2015-08-12 04:21:48
【问题描述】:
我正在为我学校的活动创建一个注册表单,但是对 PHP 和数据库非常陌生,这对我来说是一项艰巨的工作。
问题是表单向表格提交了空白数据。我可以看到每次提交都会创建一个新行,但是数据是空白的。
代码如下:
部分 index.html中的表单
<form action="input.php" method="post">
<p>
<input name="prefix" type="radio" id="male"/>
<label for="male">นาย/เด็กชาย</label>
</p>
<p>
<input name="prefix" type="radio" id="female"/>
<label for="female">นางสาว/เด็กหญิง</label>
</p>
<div class="row">
<div class="col s12">
<div class="input-field col s12 m6">
<input id="firstname" type="text" class="validate"/>
<label for="firstname">ชื่อ</label>
</div>
<div class="input-field col s12 m6">
<input id="lastname" type="text" class="validate"/>
<label for="lastname">นามสกุล</label>
</div>
.
.
.
.
<button class="btn btn-large waves-effect waves-light red accent-4" type="submit" name="submit">ส่ง</button>
</form>
input.php
<?php
mysql_connect("localhost", "acsp", "passwordhidden");
mysql_select_db("logicgames");
$order = "INSERT INTO data_logicgames (prefix, firstname, lastname, phone, school, teammate1, teammate2, games, division) VALUES ('$prefix', '$firstname', '$lastname', '$phone', '$school', '$teammate1', '$teammate2', '$games', '$division')";
$result = mysql_query($order);
if ($result) {
echo "<p>Success</p>";
} else {
echo "<p>Failed</p>";
}
?>
【问题讨论】: