搜尋

首頁  >  問答  >  主體

在下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=" https://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'>2563 天前</span><span class='pl-10'>1451 <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="https://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="https://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><footer><div class="footer"><div class="footertop"><img src="/static/imghwm/logo.png" alt=""><p>公益線上PHP培訓,幫助PHP學習者快速成長!</p></div><div class="footermid"><a href="https://m.php.cn/zh-tw/about/us.html">關於我們</a><a href="https://m.php.cn/zh-tw/about/disclaimer.html">免責聲明</a><a href="https://m.php.cn/zh-tw/update/article_0_1.html">Sitemap</a></div><div class="footerbottom"><p> © php.cn All rights reserved </p></div></div></footer><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>