我正在使用两个简单的单选按钮并尝试传递值,然后使用 $_POST 变量来读取值,但设置的值是空的
<form style="text-align:left;margin-left:80px;" class="form-inline signup" role="form" method="post" action="userdet.php">
<div class="form-group" style="padding-bottom:7px;">
<input type="text" name="first" class="form-control" placeholder="First Name" />
<input type="text" name="last" class="form-control" placeholder="Last Name" />
</div>
<div class="form-group" style="padding-bottom:7px;">
<input type="email" name="email" class="form-control" placeholder="Your Email" />
</div>
<div class="form-group" style="padding-bottom:7px;">
<input type="email" name="re-email" class="form-control" placeholder="Re-enter Email" />
</div>
<div class="form-group" style="padding-bottom:7px;">
<input type="password" name="password" class="form-control" placeholder="New Password" />
</div>
<span class="help-block">Birthday</span>
<div class="form-group" style="padding-bottom:7px;">
<select name="day" class="form-control" style="width:100px">
<?php
for($i=1;$i<=31;$i++)
{
echo '<option value='.$i.'>'.$i.'</option>';
}
?>
</select>
<select name="month" class="form-control">
<option value="January">January</option>
<option value="February">February</option>
<option value="Mars">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
<select name="year" class="form-control" style="width:120px">
<?php
for($i=1980;$i<=2015;$i++)
{
echo '<option value='.$i.'>'.$i.'</option>';
}
?>
</select>
</div>
<div class="form-group" style="padding-bottom:7px;">
<label class="radio inline" ><input type="radio" style="visibility:hidden;margin-left:-70px" value="not specified" name="gender" checked/></label>
<label class="radio inline" ><input type="radio" value="female" name="gender" />Female</label>
<label class="radio inline"><input type="radio" value="male" name="gender" />Male</label>
</div>
<div class="form-group" style="margin-top:12px;">
<button type="submit" class="btn btn-primary" name="submit">Sign Up</button>
</div>
</form>
$_POST['gender']
变量已设置,但即使选中了收音机,它的值也为空。所有其他帖子变量都正常工作。
在 php 代码中,我现在只是使用 echo 一个一个地打印值。
这段代码可能有什么问题?