开发者

Notice: Undefined index: ag in E:\wamp\www\upload files\nestedif.php on line 3

<html>
<body>
<form name="fm" action="C:\wamp\www\control\nestedif.php" method="post">
<h1 align=center>
Age<input type="text" name="ag"><br>
gender<input type="radio" name="gn" value="M">M
<input type=radio name=gn value="F">F<br>
<input type=submit name=submit value=submit>
<input type=reset name=reset value=reset>
</h1>
</form>
</body>
</html>

<h1 align=center>
<?php
$age=$_POST ['ag']开发者_高级运维;
$gen=$_POST['gn'];
if($age>=18)
{
    if($gen=="M")
    {
        echo "you are allowed to party";
    }
    else
    { 
        echo "you are not male,so that not allowed to party";
    }
}
else
{
    echo "you are not major, so that not allowed to party";
}
?>
</h1>

Notice: Undefined index: ag in E:\wamp\www\upload files\nestedif.php on line 3

Notice: Undefined index: gn in E:\wamp\www\upload files\nestedif.php on line


The 'ag' and 'gn' keys do not exist in the $_POST array, use isset to check if they do:

if(!isset($_POST['ag']) || !isset($_POST['gn'])) {
   //throw error here...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜