Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4462911
  • 博文数量: 1148
  • 博客积分: 25453
  • 博客等级: 上将
  • 技术积分: 11949
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-06 21:14
文章分类

全部博文(1148)

文章存档

2012年(15)

2011年(1078)

2010年(58)

分类: 系统运维

2011-08-25 19:30:15


  1. <?php
  2.         // 这里提交的 _POST['name1'] 与 html中 name = name1 要一致

  3.         function validataEmail($email)
  4.         {
  5.                 $regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,6})$";
  6.                 if(eregi($regexp,$email))return 1;
  7.                 else
  8.                         return 0;
  9.         } 

  10.         if(isset($_POST['submit']))
  11.         {
  12.                 $name = htmlentities($_POST['name1']);
  13.                 $email = htmlentities($_POST['email1']);
  14.                 printf("hi %s
    "
    ,$name);
  15.                 if(validataEmail($email))
  16.                         printf("the address %s will soon be a spam-magnet
    "
    ,$email);
  17.                 else
  18.                         printf("bad email
    "
    );
  19.         }
  20. ?>

  1. <form action = "test7.php" method = "post">
  2.         <p>
  3.                 Name:<br />
  4.                 <input type="text" id = "name" name = "name1" size = "20" maxlength = "40" />
  5.         </p>
  6.         <p>
  7.                 Email Address:<br />
  8.                 <input type = "text" id = "email" name = "email1" size = "20" maxlength = "40" />
  9.         </p>
  10.         <input type = "submit" id = "submit" name = "submit" value = "Go" />
  11. </form>

  12. //注意 name = "name 1" 与 POST中 配合






阅读(846) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~