富贵资源网 Design By www.hznty.com
本文实例讲述了php校验表单检测字段是否为空的方法。分享给大家供大家参考。具体如下:
php校验表单,检测字段是否为空,当表单中有未填写的字段,则会显示错误信息。
<html> <body> <form METHOD="POST" ACTION="ErrorCheck.php"> <h1>Contact Information</h1> <label>Nickname:</label> <input TYPE="TEXT" NAME="nickname"> <label>Title:</label> <input TYPE="TEXT" NAME="title"> <br /> <input TYPE="SUBMIT" VALUE="Submit"> <br /> <input TYPE="RESET" VALUE="Clear the Form"> </form> </body> </html>
php后端代码,保存为: ErrorCheck.php
<html> <body> <"<br /><b>Nickname</b> is required."; $errorcount++; } if (!trim($_POST['title'])) { echo "<br /><b>Title</b> is required."; $errorcount++; } if ($errors > 0) echo "<br /><br />Please use your browser's back button " . "to return to the form, and correct error(s)"; "htmlcode">" " (ASCII 32 (0×20)), an ordinary space. "\t" (ASCII 9 (0×09)), a tab. "\n" (ASCII 10 (0x0A)), a new line (line feed). "\r" (ASCII 13 (0x0D)), a carriage return. "\0″ (ASCII 0 (0×00)), the NUL-byte. "\x0B" (ASCII 11 (0x0B)), a vertical tab.希望本文所述对大家的php程序设计有所帮助。
富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com
暂无评论...