标题: php 表单求助
时间: 2014-03-06
<?php
echo '
<form action="index.php" method="post">
<input name="n1"><br>
<input name="n2"><br>
<input type="submit" name="js" value="加">
<input type="submit" name="js" value="减">
<input type="submit" name="js" value="乘">
<input type="submit" name="js" value="除">
</form>';
$n1 = $_POST['n1'];
$n2 = $_POST['n2'];
$js = $_POST['js'];
if ($js=='加')
$jg=$n1+$n2;
if ($js=='减')
$jg=$n1-$n2;
if ($js=='乘')
$jg=$n1*$n2;
if ($js=='除' and $n2!=0)
$jg=$n1/$n2;
if ($js=='除' and $n2==0)
$jg='除数不能为0!';
echo '结果:'.$jg;
?>
为什么不发送任何数据就会 Notice: Undefined index: n1 in /data/data/android.wwwroot/index.php on line 11『回复列表(9|隐藏机器人聊天)』