首页  >  问答  >  正文

在下php表单验证时 出现 Notice: Undefined index: email in F:\apache\Apache24\htdocs\chap01\form1.php on line 21要怎么办。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

表单验证< ;/title></p><p><meta http-equiv="Content-Type" content="text/html; charset=utf-8" //></p><p><meta name="描述" content="" //></p><p><元名称="keywords" content="" //></p><p><脚本类型="text/javascript"></p><p><br/></p>##</script><p></p><p><br/>##<样式类型=“text/css”></p><p></style></p><p></head></p><p>    <body></p><p>    <?php</p><p>$name = $email =$性别 =$comment = $website ="";</p><p></p><p><br/>#if($_SERVER["REQUEST_METHOD"] == "POST"){</p><p>    $name = test_input($_POST["姓名"]);</p><p>    $email = test_input($_POST["电子邮件"]);</p><p>    $website = test_input($_POST["网站"] );</p><p>    $comment = test_input($_POST["comment"]);</p><p>    $gender = test_input($_POST["gender"]);</p><p>}</p><p>function test_input($data){</p><p>    $data = trim($data);</p><p>    $data = stripslashes($data);</p><p>    $data = htmlspecialchars($data);</p><p>    return $data;</p><p>}</p><p>?></p><p></p><p><br/>#< h2> php 验证实列</h2></p><p><form method="post" action ="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"></p><p>姓名:<input type="text" name ="name"></p><p><br><br></p><p> 符号:<input type="text " email ="电子邮件"></p><p><br><br></p><p>网址:<输入类型="文本" website ="网站"></p><p><br><br></p><p>评论:<input type="text" comment = "comment"></p><p><br><br></p><p>性别:</p><p><input type="radio" name ="gender" vlaue ="female">女性</p><p><input type="radio" name ="gender" vlaue="男">男性</p><p><br><br></p><p><input type="submit" name="submit" value = "提交"></p><p></form></p><p></p><p><br/>#<?php</p><p>echo "<h2>您的输入为:</h2> ";</p><p>echo "<br>";</p><p>echo $name;</p><p>echo "<br>";</p><p>echo $email; </p><p>echo "<br>";</p><p>echo $website;</p><p>echo "<br>";</p><p>echo $comment;</p><p>echo "<br>";</p><p>echo $gender;</p><p>?></p><p>    </body></p><p></html> </p><p><br/></p></div><div class='info mb-10'><a rel="nofollow" href=" http://m.php.cn/zh/member/61561.html"><img src='https://img.php.cn/upload/avatar/000/000/001/848c1057219871ff561ea5fb2c35dc0f.jpg' alt="W"><span style="margin-left: 5px;">W</span></a><span class='pl-10'>2551 天前</span><span class='pl-10'>1431 <b class="kclbcollectb"></b></span></div></div><div class="course-list discuss layui-clear bg-white"><h3>全部回复(2)<span class="detail_answer"><span id="discuss-wenda">我来回复</span></span></h3><li class="layui-clear"><div class="discuss-img"><img src="/static/images/user_avatar.jpg" alt="乘易网络"></div><div class="info f-left ml-10"><p><a rel="nofollow" href="http://m.php.cn/zh/member/61717.html" fid="" class="replyer-name">乘易网络</a><span>2017-11-17 16:37:28</span></p><p class="content Overflow_line"><p>input 的email 没有name属性 服务端怎么获取?</p></p><span class="detail_answer2" style="float: left" fid="232454"><div class="btn wenda-second-btn" name="乘易网络" fid="232454">回复</div></span><i class="layui-icon layui-icon-praise wenda-praise-btn"><span>0</span></i></div></li><li class="layui-clear"><div class="discuss-img"><img src="/static/images/user_avatar.jpg" alt="phpcn_u61612"></div><div class="info f-left ml-10"><p><a rel="nofollow" href="http://m.php.cn/zh/member/61612.html" fid="" class="replyer-name">phpcn_u61612</a><span>2017-11-17 14:34:41</span></p><p class="content Overflow_line"><p><img src="http://img.php.cn//upload/image/285/857/175/1510900385407770.png" title="1510900385407770.png" alt="QQ截图20171117142103.png"/></p><p><img src="http://img.php.cn//upload/image/814/390/805/1510900389254312.png" title="1510900389254312.png" alt="QQ截图20171117142130.png"/></p>rree<p><br/></p></p><span class="detail_answer2" style="float: left" fid="232440"><div class="btn wenda-second-btn" name="phpcn_u61612" fid="232440">回复</div></span><i class="layui-icon layui-icon-praise wenda-praise-btn"><span>1</span></i></div></li><div class='more'></div></div><div class='discuss-submit bg-white'><li class='info layui-clear'><span class='f-left' id='discuss-submit-close'>取消</span><span class='f-left wenda-reply-text'>回复</span></li><li class='layui-clear'><textarea type='text' rows="6" placeholder="请输入您的评论内容" class="wenda-reply-content-text"></textarea></li><li class='layui-clear'><button class="layui-btn layui-btn-danger f-right wenda-reply-publish-button">发布</button></li></div><div class='lock-screen' id='lock-screen'></div><script src="/static/ueditor/third-party/SyntaxHighlighter/shCore.js"></script><div class="headerMask"></div><link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css' type='text/css' media='all'/><script type='text/javascript' src='/static/js/viewer.min.js?1'></script><script type='text/javascript' src='/static/js/jquery-viewer.min.js'></script><div class="nphpFoot"><div class="nphpFootBg"><ul class="nphpFootMenu"><li><a href="http://m.php.cn/zh/"><b class="icon1"></b><p>首页</p></a></li><li><a href="http://m.php.cn/zh/course.html"><b class="icon2"></b><p>课程</p></a></li><li><a href="http://m.php.cn/zh/wenda.html"><b class="icon4"></b><p>问答</p></a></li><li><a href="http://m.php.cn/zh/login"><b class="icon5"></b><p>我的</p></a></li><div class="clear"></div></ul></div></div><div class="nphpYouBox" style="display: none;"><div class="nphpYouBg"><div class="nphpYouTitle"><span onclick="$('.nphpYouBox').hide()"></span><a href="http://m.php.cn/zh/"></a><div class="clear"></div></div><ul class="nphpYouList"><li><a href="http://m.php.cn/zh/"><b class="icon1"></b><span>首页</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/zh/course.html"><b class="icon2"></b><span>课程</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/zh/article.html"><b class="icon3"></b><span>文章</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/zh/wenda.html"><b class="icon4"></b><span>问答</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/zh/dic.html"><b class="icon6"></b><span>词典</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/zh/course/type/99.html"><b class="icon7"></b><span>手册</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/zh/xiazai/"><b class="icon8"></b><span>下载</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/zh/faq/zt" title="专题"><b class="icon12"></b><span>专题</span><div class="clear"></div></a></li><div class="clear"></div></ul></div></div><div class="nphpDing" style="display: none;"><div class="nphpDinglogo"><a href="http://m.php.cn/zh/"></a></div><div class="nphpNavIn1"><div class="swiper-container nphpNavSwiper1"><div class="swiper-wrapper"><div class="swiper-slide"><a href="http://m.php.cn/zh/" >首页</a></div><div class="swiper-slide"><a href="http://m.php.cn/zh/article.html" >文章</a></div><div class="swiper-slide"><a href="http://m.php.cn/zh/wenda.html" class="hover">问答</a></div><div class="swiper-slide"><a href="http://m.php.cn/zh/course.html" >课程</a></div><div class="swiper-slide"><a href="http://m.php.cn/zh/faq/zt" >专题</a></div><div class="swiper-slide"><a href="http://m.php.cn/zh/xiazai" >下载</a></div><div class="swiper-slide"><a href="http://m.php.cn/zh/game" >手游</a></div><div class="swiper-slide"><a href="http://m.php.cn/zh/dic.html" >词典</a></div><div class="clear"></div></div></div><div class="langadivs" ><a href="javascript:;" class="bg4 bglanguage"></a><div class="langadiv" ><a onclick="javascript:setlang('zh-cn');" class="language course-right-orders chooselan " href="javascript:;"><span>简体中文</span><span>(ZH-CN)</span></a><a onclick="javascript:setlang('en');" class="language course-right-orders chooselan " href="javascript:;"><span>English</span><span>(EN)</span></a><a onclick="javascript:setlang('zh-tw');" class="language course-right-orders chooselan " href="javascript:;"><span>繁体中文</span><span>(ZH-TW)</span></a><a onclick="javascript:setlang('ja');" class="language course-right-orders chooselan " href="javascript:;"><span>日本語</span><span>(JA)</span></a><a onclick="javascript:setlang('ko');" class="language course-right-orders chooselan " href="javascript:;"><span>한국어</span><span>(KO)</span></a><a onclick="javascript:setlang('ms');" class="language course-right-orders chooselan " href="javascript:;"><span>Melayu</span><span>(MS)</span></a><a onclick="javascript:setlang('fr');" class="language course-right-orders chooselan " href="javascript:;"><span>Français</span><span>(FR)</span></a><a onclick="javascript:setlang('de');" class="language course-right-orders chooselan " href="javascript:;"><span>Deutsch</span><span>(DE)</span></a></div></div><script> var swiper = new Swiper('.nphpNavSwiper1', { slidesPerView : 'auto', observer: true,//修改swiper自己或子元素时,自动初始化swiper observeParents: true,//修改swiper的父元素时,自动初始化swiper }); </script></div></div><!--顶部导航 end--><script>isLogin = 0;</script><script type="text/javascript" src="/static/layui/layui.js"></script><script type="text/javascript" src="/static/js/global.js?4.9.47"></script></body></html>