如何使用多个单选按钮提交表单?
步骤工作:
如果我选择单选按钮[插入类型1]
<?PHP
$sql = "INSERT INTO general_user (name , lastname)
VALUES ('$_POST[name]', '$_POST[lastname]'); ";
$dbQuery = mysql_query($sql);
?>
<form action="payments.php" method="post" name="paypal_send_data">
<input type="hidden" name="user_id" value="<?PHP echo $user_id; ?>">
</form>
<script type="text/javascript">
setTimeout(function(){paypal_send_data.submit();}, 3000);
</script>
如果我选择单选按钮[插入类型2]
<?PHP
$sql = "DELETE FROM premium_user WHERE user_id = '$user_id' ";
$objQuery = mysql_query($sql);
$sql = "INSERT INTO premium_user (name , lastname , address , tell )
VALUES ('$_POST[name]', '$_POST[lastname]', '$_POST[address]', '$_POST[tell]'); ";
$dbQuery = mysql_query($sql);
?>
<form action="payments.php" method="post" name="paypal_send_data">
<input type="hidden" name="user_id" value="<?PHP echo $user_id; ?>">
</form>
<script type="text/javascript">
setTimeout(function(){paypal_send_data.submit();}, 3000);
</script>
如果我选择单选按钮[插入类型3]
<?PHP
$sql = "DELETE FROM premium_user WHERE user_id = '$user_id' ";
$objQuery = mysql_query($sql);
?>
<form action="payments.php" method="post" name="paypal_send_data">
<input type="hidden" name="user_id" value="<?PHP echo $user_id; ?>">
</form>
<script type="text/javascript">
setTimeout(function(){paypal_send_data.submit();}, 3000);
</script>
这是我的表格代码。
<form name="ratebox" action="" method="post">
<table style="margin: 0 auto;">
<tr>
<td>Name :</td><td><input type="text" name="name" value=""/></td>
</tr>
<tr>
<td>Last-Name :</td><td><input type="text" name="lastname" value=""/></td>
</tr>
<tr>
<td>Tell. :</td><td><input type="text" name="tell" value=""/></td>
</tr>
<tr>
<td>Address :</td><td><input type="text" name="address" value=""/></td>
</tr>
<tr>
<td>Last-Name :</td><td><input type="text" name="lastname" value=""/></td>
</tr>
<tr>
<td>Insert type 1</td><td><input type="radio" name="rdoRate"></td>
</tr>
<tr>
<td>Insert type 2</td><td><input type="radio" name="rdoRate"></td>
</tr>
<tr>
<td>Insert type 3</td><td><input type="radio" name="rdoRate"></td>
</tr>
</table>
</form>