Chinaunix首页 | 论坛 | 博客
  • 博客访问: 707847
  • 博文数量: 143
  • 博客积分: 1554
  • 博客等级: 上尉
  • 技术积分: 1767
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-10 11:50
文章分类

全部博文(143)

文章存档

2017年(2)

2016年(5)

2015年(16)

2014年(25)

2013年(27)

2012年(16)

2011年(52)

分类: PHP

2013-12-25 22:04:46



1.建立php文件判断处理

点击(此处)折叠或打开

  1. <?php
  2.   
  3. if($_POST) {
  4.     $name = $_POST['name'];
  5.     $email = $_POST['email'];
  6.     $username = $_POST['username'];
  7.     $password = $_POST['password'];
  8.     $gender = $_POST['gender'];
  9. // Full Name
  10.     if (eregi('^[A-Za-z0-9 ]{3,20}$',$name)){
  11.            $valid_name=$name;
  12.      }else{
  13.            $error_name='Enter valid Name.';
  14.      }
  15. // Email
  16.     if (eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})$', $email)){
  17.            $valid_email=$email;
  18.      }else{
  19.         $error_email='Enter valid Email.';
  20.      }
  21. // Usename min 2 char max 20 char
  22.     if (eregi('^[A-Za-z0-9_]{3,20}$',$username)){
  23.            $valid_username=$username;
  24.      }else{
  25.         $error_username='Enter valid Username min 3 Chars.';
  26.      }
  27.   
  28. // Password min 6 char max 20 char
  29.   
  30.     if (eregi('^[A-Za-z0-9!@#$%^&*()_]{6,20}$',$password)){
  31.           $valid_password=$password;
  32.      }else{
  33.         $error_password='Enter valid Password min 6 Chars.';
  34.      }
  35.   
  36. // Gender
  37.     if ($gender==0){
  38.             $error_gender='Select Gender';
  39.      }else{
  40.             $valid_gender=$gender;
  41.     }
  42.   
  43.     if((strlen($valid_name)>0)&&(strlen($valid_email)>0)&&(strlen($valid_username)>0)&&(strlen($valid_password)>0) && $valid_gender>0 ){
  44.     //mysql_query(' SQL insert statement');
  45.         header("Location: thanks.html");
  46.     }
  47.     else{
  48.     }
  49.       
  50. }
  51. ?>
2.建立一个表单

点击(此处)折叠或打开

  1. <html>
  2. <head>
  3.     <title></title>
  4. <style type="text/css">
  5.     .err{
  6.     font-size:11px;
  7.     padding-left:10px;
  8.     color:#CC0000;
  9.     float:left;}
  10.     input{
  11.     float:left;
  12.     }
  13. </style>
  14. </head>
  15. <body>
  16. <form autocomplete="off" enctype="multipart/form-data" method="post" action="" name="form">
  17.   
  18.   
  19.   
  20. <ul>
  21.           
  22.       
  23. <li id="foli1" class=" ">
  24.     <label class="desc" id="title1" for="Field1">Full Name</label>
  25.     <div>
  26.      <input id="name" name="name" type="text" class="field text medium" value="" maxlength="255" tabindex="1" /><span class="err"> <?php echo $error_name; ?></span>
  27.     </div>
  28. </li>
  29.       
  30.   
  31. <li id="foli2" class=" ">
  32.     <label class="desc" id="title2" for="Field2">Email</label>
  33.     <div>
  34.         <input id="email" name="email" type="text" class="field text medium" value="" maxlength="255" tabindex="2" /><span class="err"> <?php echo $error_email; ?></span>
  35.         </div>
  36.     </li>
  37.   
  38.   
  39. <li id="foli3" class=" ">
  40.     <label class="desc" id="title3" for="Field3">
  41.         User-ID </label>
  42.     <div>
  43.         <input id="username" name="username" type="text" class="field text medium" value="" maxlength="255" tabindex="3" /><span class="err"> <?php echo $error_username; ?></span>
  44.         </div>
  45.     </li>
  46.    
  47. <li id="foli4" class=" ">
  48.     <label class="desc" id="title4" for="Field4">Password </label>
  49.     <div>
  50.         <input id="password" name="password" type="password" class="field text medium" value="" maxlength="255" tabindex="4" /><span class="err"> <?php echo $error_password; ?></span>
  51.         </div>
  52.     </li>
  53.   
  54.   
  55. <li id="foli6" class=" ">
  56.     <label class="desc" id="title6" for="Field6"> Gender</label>
  57.     <div>
  58.         <select id="gender" name="gender" class="field select medium" tabindex="5" style="float:left">
  59.                         <option value="0">Gender</option><option value="1">Male</option><option value="2">Female</option>
  60.           </select><span class="err"> <?php echo $error_gender; ?></span>
  61.     </div>
  62. </li>
  63.   
  64.   
  65. <li id="foli15" class=" "></li>
  66.   
  67.   
  68. <li class="buttons">
  69.                 <input type="submit" value="Submit" style=" background:#0060a1; color:#FFFFFF; font-size:14px; border:1px solid #0060a1"/>
  70. </li>
  71.   
  72.       
  73. </ul>
  74. </form>

  75. </body>
  76. </html>


阅读(771) | 评论(0) | 转发(0) |
0

上一篇:数据库中DDL和DML说明

下一篇:PHP验证码

给主人留下些什么吧!~~