搜索

首页  >  问答  >  正文

在下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=" https://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'>2564 天前</span><span class='pl-10'>1454 <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/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/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><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/about/us.html">关于我们</a><a href="https://m.php.cn/zh/about/disclaimer.html">免责声明</a><a href="https://m.php.cn/zh/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>