首頁  >  問答  >  主體

在下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><p></script></p><p><br/></p>##<樣式類型=“text/css”><p></p></style><p></p> #</head><p></p>    <body><p></p>    <?php<p></p>$name = $email =$性別=$comment = $website ="";<p> </p><p><br/></p>#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><p></p><p></p><p></p><p><br/></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p> #    return $data;<p></p>}<p></p>?><p><br/></p><p></p>##< 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>#######網址:<輸入類型="文字" website ="網站">###### #< br><br>######評論:<input type="text" comment = "comment">######<br><br>#### ##性別:######<input type="radio" name ="gender" vlaue ="female">女性######<input type="radio" name ="gender" vlaue="男"> ;男######<br><br>######<input type="submit" name="submit" value = "提交">## ####</form >################<?php######echo "<h2>您的輸入為:</h2> ";######echo " <br>";######echo $name;######echo "<br>";######echo $email; ###<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>##</html>; <p></p><p><br/></div><div class='info mb-10'><a rel="nofollow" href=" http://m.php.cn/zh-tw/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'>1436 <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-tw/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-tw/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><pre class="brush:php;toolbar:false"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>表单验证</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="description" content="" /> <meta name="keywords" content="" /> <script type="text/javascript"> </script> <style type="text/css"> </style> </head> <body> <?php $name = $email = $gender =$comment = $website =""; if($_SERVER["REQUEST_METHOD"] == "POST"){     $name = test_input($_POST["name"]);     $email = test_input($_POST["email"]);     $website = test_input($_POST["website"]);     $comment = test_input($_POST["comment"]);     $gender = test_input($_POST["gender"]); } function test_input($data){     $data = trim($data);     $data = stripslashes($data);     $data = htmlspecialchars($data);     return $data; } ?> <h2> php 验证实列</h2> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> 姓名:<input type="text" name="name"> <br><br> 电邮:<input type="text" name="email"> <br><br> 网址:<input type="text" name="website"> <br><br> 评论:<input type="text" name="comment"> <br><br> 性别: <input type="radio" name="gender" vlaue ="female">女性 <input type="radio" name="gender" vlaue ="male">男性 <br><br> <input type="submit" name="submit" value = "提交"> </form> <?php echo "<h2>您的输入为:</h2>"; echo "<br>"; echo $name; echo "<br>"; echo $email; echo "<br>"; echo $website; echo "<br>"; echo $comment; echo "<br>"; echo $gender; ?> </body> </html></pre><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-tw/"><b class="icon1"></b><p>首頁</p></a></li><li><a href="http://m.php.cn/zh-tw/course.html"><b class="icon2"></b><p>課程</p></a></li><li><a href="http://m.php.cn/zh-tw/wenda.html"><b class="icon4"></b><p>問答</p></a></li><li><a href="http://m.php.cn/zh-tw/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-tw/"></a><div class="clear"></div></div><ul class="nphpYouList"><li><a href="http://m.php.cn/zh-tw/"><b class="icon1"></b><span>首頁</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/zh-tw/course.html"><b class="icon2"></b><span>課程</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/zh-tw/article.html"><b class="icon3"></b><span>文章</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/zh-tw/wenda.html"><b class="icon4"></b><span>問答</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/zh-tw/dic.html"><b class="icon6"></b><span>詞典</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/zh-tw/course/type/99.html"><b class="icon7"></b><span>手册</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/zh-tw/xiazai/"><b class="icon8"></b><span>下載</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/zh-tw/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-tw/"></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-tw/" >首頁</a></div><div class="swiper-slide"><a href="http://m.php.cn/zh-tw/article.html" >文章</a></div><div class="swiper-slide"><a href="http://m.php.cn/zh-tw/wenda.html" class="hover">問答</a></div><div class="swiper-slide"><a href="http://m.php.cn/zh-tw/course.html" >課程</a></div><div class="swiper-slide"><a href="http://m.php.cn/zh-tw/faq/zt" >專題</a></div><div class="swiper-slide"><a href="http://m.php.cn/zh-tw/xiazai" >下載</a></div><div class="swiper-slide"><a href="http://m.php.cn/zh-tw/game" >遊戲</a></div><div class="swiper-slide"><a href="http://m.php.cn/zh-tw/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:;" class="language course-right-orders chooselan chooselanguage" 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>