嗨,首先让我告诉你我在这里发布我的代码的“摘要”不是因为我没有尝试解决我的问题或者我很懒惰。由于我对 PHP 的了解很少,现在努力破解错误 3.5 小时!
如果有人能指出为什么会发生此错误,我将不胜感激。该错误在第 4 行中显示未定义的错误。
<?php
function validate(&$x,&$y)
{if(isset($_POST['sub1']))
{if($_POST['optMe'] == "") {echo "Empty dropdown"; return false;}}
}
function display($x,$y)
{
?>
<html>
<head><title></title></head>
<body>
<form method="POST">
<table id="tab2" border="1">
<tr><td>
<select id="optMe">
<option value=""></option>
<option value="one">one</option>
<option value="two">two</option>
</select>
</td>
<td><input type="submit" id="sub1" name="sub1" value="Click here"></td>
</tr>
</table>
</form>
<form method="POST">
<table id="tab2" border="1">
<tr>
<td><input type="text"></td>
<td><input type="submit" id="send" name="send" value="send now"></td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
function process($x)
{
// I will add my code here to print something.
}
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{$formValues = $_POST;$formErrors = array();
if (!validate($formValues, $formErrors))
display($formValues, $formErrors);
else
process($formValues);
}
else
display(null, null);
?>