我试图将功能添加到脚本中,要求用户输入我已添加的代码。但有一个问题我希望无法何时询问用户代码以及何时询问。所以我需要一个PHP,如果否则,它的SQL因此,当我无法向用户询问代码时,它将询问代码,而当我禁用它时,它将不会询问代码以下是我尝试过的一个
if ((['yes'])) {
// Yes
<div id="cot_div" align="center">
<p>Please enter your <strong id="code_up">COT</strong> code to continue</p>
<form id="form3" name="form3" method="POST" action="inter_suc.php">
<table border="0" id="trans" align="center" >
<tr>
<td align="center" style="padding:0px"><span id="sprytextfield1">
<input name="cot" type="text" id="cot" size="10" />
<span class="textfieldRequiredMsg"></span></span>
<span id="sprytextfield2">
<input name="tax" type="text" id="tax" size="10" />
<span class="textfieldRequiredMsg"></span></span>
<span id="sprytextfield3">
<input name="imf" type="text" id="imf" size="10" />
<span class="textfieldRequiredMsg"></span></span><br /> <span id="error">
wrong COT Code</span>
</td>
</tr>
<tr>
<td align="center" style="padding:0px"><input type="button" name="go" id="go" value="Go" />
<input type="button" name="go2" id="go2" value="GO" />
<input type="button" name="go3" id="go3" value="GO" />
</td>
</tr>
} else {
// No
<div id="cot_div" align="center">
<p>Please enter your <strong id="code_up">COT</strong> code to continue</p>
<form id="form3" name="form3" method="POST" action="inter_suc.php">
<table border="0" id="trans" align="center" >
<tr>
<td align="center" style="padding:0px"><span id="sprytextfield1">
<input name="cot" type="hidden" id="cot" value="<?php echo $_POST['cot'];?>" />
<span class="textfieldRequiredMsg"></span></span>
<span id="sprytextfield2">
<input name="tax" type="hidden" id="tax" value="<?php echo $_POST['tax'];?>" />
<span class="textfieldRequiredMsg"></span></span>
<span id="sprytextfield3">
<input name="imf" type="hidden" id="imf" value="<?php echo $_POST['imf'];?>" />
<span class="textfieldRequiredMsg"></span></span><br /> <span id="error">
wrong COT Code</span>
</td>
</tr>
<tr>
<td align="center" style="padding:0px"><input type="button" name="go" id="go" value="Go" />
<input type="button" name="go2" id="go2" value="GO" />
<input type="button" name="go3" id="go3" value="GO" />
</td>
</tr>
}
如果我理解您的回答是正确的,那么如果您在php中给定的变量为'是',则您想显示特定的HTML部分。否则,您想显示HTML的其他部分。
比您可以使用以下语法:
<?php if ($val = 'YES'): ?>
<!-- Yes part -->
<?php else: ?>
<!-- No part -->
<?php endif; ?>
您的意思是这样的?
.error {
display: none
}
<?php
$yes = $_GET["yes"] == "yes"; ?>
<div id="cot_div" align="center">
<p>Please enter your <strong id="code_up">COT</strong> code to continue</p>
<form id="form3" name="form3" method="POST" action="inter_suc.php">
<table border="0" id="trans" align="center">
<tr>
<td align="center" style="padding:0px">
<span id="sprytextfield1"><input name="cot" type="<?php echo $yes ? "text" : "hidden"; ?>" id="cot" size="10" /></span>
<span class="textfieldRequiredMsg"></span>
<span id="sprytextfield2"><input name="tax" type="<?php echo $yes ? "text" : "hidden"; ?>" id="tax" size="10" /></span>
<span class="textfieldRequiredMsg"></span>
<span id="sprytextfield3"><input name="imf" type="<?php echo $yes ? "text" : "hidden"; ?>" id="imf" size="10" /></span>
<span class="textfieldRequiredMsg"></span><br />
<span id="error">wrong COT Code</span>
</td>
</tr>
<tr>
<td align="center" style="padding:0px">
<input type="button" name="go" id="go" value="Go" />
<input type="button" name="go2" id="go2" value="GO" />
<input type="button" name="go3" id="go3" value="GO" />
</td>
</tr>
</table>
</div>