当我使用我的程序时,我遇到了一个未知错误。发生的事情是我的代码绕过了两个if
语句。这是我的代码:
<?
session_start();
if ($_POST){
$ao = trim($_POST['amountof']);
$continue = true;
if (strlen($ao) < 1){ ####First If-Statement Bypassed####
$continue = false;
$_SESSION['error'] = "Please enter in a value!";
}
if (strlen($ao) > 20){ ####Second If-Statement Bypassed####
$continue = false;
$_SESSION['error'] = "Your value has exceeded 20!";
}
if (!is_numeric($ao)){
$continue = false;
$_SESSION['error'] = "Value is not numeric!";
}
}
?>
<form method="post">
<?
if (isset($_SESSION['error'])){
print "<span style=\"color: red; font-weight: bold;\">" . $_SESSION['error'] . " </span><br />";
}
?>
How many letters are you planning to process?<br />
<span style="font-size:.8em; color: grey;">You may not exceed 20</span><br />
<input type="text" name="amountof" style="width:25px;" maxlength="2"/>
<input type="submit" value="Continue" />
</form>
<? unset($_SESSION['error']); ?>
被绕过的 if 语句在代码中被标记。谢谢!