我有一个带3个单选按钮的引导程序表单。我将值保存到变量中,以便我可以用来保存到数据库和电子邮件中。
HTML:
<form class="form-horizontal form-validate" id="signup-form" method="post">
<input type="hidden" name="signupForm" />
<div class="control-group">
<label class="control-label">Seed program</label>
<div class="controls">
<input type="radio" name="signup" value="Seed Program" checked="checked"/>
</div>
</div>
<div class="control-group">
<label class="control-label">Gift Wrap Program</label>
<div class="controls">
<input type="radio" name="signup" value="Gift Wrap" />
</div>
</div>
<div class="control-group">
<label class="control-label">Sign up for both</label>
<div class="controls">
<input type="radio" name="signup" value="Both" />
</div>
</div>
<input type="submit" class="btn btn-large btn-block btn-success" value="Submit" name="submit">
</form>
PHP:
if(isset($_POST['signupForm'])){
if(isset($_POST['signup'])) {
$signup = $_POST["signup"];
}
else{
$signup = "Nothing was selected";
}
}
问题:
问题是我只能获得具有“已检查”属性的第一个单选按钮的值。如果我选择其他两个中的任何一个,我什么都得不到,值显示为空。
感谢任何帮助。
谢谢,
答案 0 :(得分:0)
尝试使用
<input type="radio" name="signup" value="Seed Program" checked="checked"/>
而不是
<?php
$selected_admin = find_admin_by_id($_GET["admin"]);
if (!$selected_admin) { redirect_to("sadmin.php");
}
while ($admin = mysqli_fetch_assoc($selected_admin))
{
$admin_id = $admin["admin_id"];
}
if( intval($admin_id) > 0 ){
$sql = "delete from admin where admin_id = {$admin_id} limit 1";
$result = mysqli_query($connection, $sql);
if ($result && mysqli_affected_rows($connection) == 1)
{
$SESSION["message"] = "Admin successfully deleted.";
redirect_to("sadmin.php");
}
else {
$SESSION["message"] = "Admin was not deleted successfully."; redirect_to("sadmin.php?admin={$admin_id}");
}
}
?>