这是我的 PHP 代码
我在代码部分的注释中提到的问题点
if(isset($_POST['submit']))
{
if(isset($_POST['rdoption1']))
{
$var1 = $_POST["rdoption1"];
}
if(isset($_POST['rdoption2']))
{
$var2 = $_POST["rdoption2"];
}
if(!isset($_POST['rdoption1']))
{
$message = "Please select Option1";
}
elseif(!isset($_POST['rdoption2']))
{
$message = "Please select Option2";
}
elseif($_POST['rdoption2'] == "checkSetXY")
{
if($_POST["valXLocation"] == "")
{
$message = "You forget to enter X value.";
}
elseif($_POST["valYLocation"] == "")
{
$message = "You forget to enter Y value.";
}
} // till here all is good. I get all error messages if anything is left vacant or not clicked on radio button
elseif(empty($_POST['txtoption3'])) //this is not working //the issue is if i select rdoption1 any option and rdoption2 checkDefault next code logic work.. but next code logic does not work when i click on the radio of checkSetXY and enter x and y values.. It simply does not execute code further..
{
$message = "Please enter your name.";
}
else
{
//insert into db
}
}
这是带有 PHP 回显的 html 表单在这里我收到消息应该在的地方,但在我选择checkSetXY
值时没有
<?php if(!empty($message)){ echo $message; } ?>
<form id="form1" name="form1" method="post" action="form1.php">
Space portion:
<input type="radio" name="rdoption1" value="RJ"/>space 1
<input type="radio" name="rdoption1" value="SM" />space 2
Pixel Location
<div class="formText">
<input type="radio" name="rdoption2" value="checkSetXY"/> Specify Location
X: <input type="text" id="locField" name="valXLocation">
Y: <input type="text" id="locField" name="valYLocation">
<input type="radio" name="rdoption2" value="checkDefault"/>Default
<input type="text" class="input" name="txtoption3">
<input type="submit" name="submit" value="Submit">
</form>
现在我很困惑为什么不elseif
考虑txtoption3
有什么帮助吗?提前致谢