分享
 
 
 

PHP PEAR/HTML/QuickForm实现用户注册表单界面

王朝php·作者佚名  2006-11-24
窄屏简体版  字體: |||超大  

用PEAR中的QuickForm实现了一个用户注册的界面,具体的操作数据库没有写。可能是我还不太熟练吧,没发现它的优点,反而不如JS,HTML直接编写来得迅速。也许它的好处就是可以控制很多吧(不是指外观)。下面的例子就实现了用户名,EMAIL地址的格式检查,证件号码等等的检查,当然这些用JS都可以轻松完成的,大家见仁见智吧。下面是最终效果图:

下面是PHP代码

<?php

/**

* QuickForm手工篇

*

* QuickForm手工输入之熟练篇

* 用QuickForm完成一个用户注册页面(包括信息的审查功能)

* @author jxyuhua at gmail.com

*/

require_once("HTML/QuickForm.php");

echo("<link rel="stylesheet" href="css.css" />");

$quickForm = new HTML_QuickForm("registerFrm");

$country = array("1" => "中国",

"2" => "日本",

"3" => "美国",

"4" => "英国",

"0" => "其它");

$city = array("1" => "北京",

"2" => "广东",

"3" => "江西",

"0" => "其它");

$industry = array("1" => "学生",

"2" => "科研机构",

"3" => "IT产业",

"0" => "其它");

$from = array("1" => "网吧",

"2" => "单位",

"3" => "家里",

"0" => "其它");

$quickForm->setDefaults(array("idtype" => 1,

"secret" => 1));

$quickForm->addElement("header", null, "新用户注册");

$quickForm->addElement("text", "name", "用户登录呢称:", array("size" => 20, "maxlength" => 20));

$quickForm->addElement("password", "pass", "密码:", array("size" => 20, "maxlength" => 20));

$quickForm->addElement("password", "repass", "重复输入密码:", array("size" => 20, "maxlength" => 20));

$quickForm->addElement("text", "email", "EMAIL地址:", array("size" => 20, "maxlength" => 50));

$quickForm->addElement("text", "passquestion", "密码提示问题:", array("size" => 50, "maxlength" => 50));

$quickForm->addElement("text", "passanswer", "密码提示答案:", array("size" => 50, "maxlength" => 50));

$quickForm->addElement("text", "alias", "用户中文呢称:", array("size" => 30, "maxlength" => 50));

$quickForm->addElement("textarea", "description", "个人描述信息:", array("rows" => 3, "cols" => 50, "class" => "textBox"));

$radio[] = &$quickForm->createElement("radio", null, null, "以下信息对不外公开", "1");

$radio[] = &$quickForm->createElement("radio", null, null, "以下信息对外公开", "0");

$quickForm->addGroup($radio, "secret");

//?如何设置默认选中为身份证?

//中转的办法,设默认值

$quickForm->addElement("text", "idnuber", "证件号码:", array("size" => 30, "maxlength" => 30));

$radio2[] = $quickForm->createElement("radio", "idtype", null, "身份证", null, array("value" => 1, "checked" => "true"));

$radio2[] = $quickForm->createElement("radio", "idtype", null, "其它证件", null, array("value" => 2));

$quickForm->addGroup($radio2);

$quickForm->addElement("text", "realname", "真实姓名:", array("size" => 20, "maxlength" => 30));

$quickForm->addElement("select", "gender", "性别:", array("male" => "男", "female" => "女"));

$quickForm->addElement("date", "born", "出生于:", array("format" => "Y 年m 月d", "minYear" => 1940, "maxYear" => 1995));

$quickForm->addElement("select", "country", "所在国家:", $country);

$quickForm->addElement("select", "city", "省(市):", $city);

$quickForm->addElement("text", "town", "市(县):", array("size" => 20, "maxlength" => 20));

$quickForm->addElement("text", "address", "联系地址:", array("size" => 50, "maxlength" => 50));

$quickForm->addElement("text", "zipcode", "邮政编码:", array("size" => 20, "maxlength" => 20));

$quickForm->addElement("text", "phone", "联系电话:", array("size" => 20, "maxlength" => 20));

$quickForm->addElement("text", "company", "所在单位:", array("size" => 30, "maxlength" => 30));

$quickForm->addElement("text", "department", "所在部门:", array("size" => 20, "maxlength" => 20));

$quickForm->addElement("select", "industry", "所在行业:", $industry);

$quickForm->addElement("select", "source", "主要在哪里<br />访问我们的网站:", $from);

$quickForm->addElement("text", "webpage", "个人主页:", array("size" => 50, "maxlength" => 50));

$quickForm->addElement("submit", null, "注册用户");

//设定表单的规则

$quickForm->applyFilter("name", "trim");

$quickForm->addRule("name", "用户登录昵称必须填写!!", "required");

$quickForm->addRule("pass", "密码不能为空", "required");

$quickForm->addRule("email", "电子邮件EMAIL不能为空", "required");

$quickForm->addRule("passquestion", "请填写密码提示问题", "required");

$quickForm->addRule("passanswer", "请填写密码提示答案", "required");

$quickForm->addRule("idnuber", "请填写证件号码", "required");

$quickForm->addRule("realname", "请填写真实姓名", "required");

$quickForm->addRule("gender", "性别不能为空", "required");

$quickForm->addRule("born", "出生日期不能为空", "required");

$quickForm->addRule("country", "国家不能为空", "required");

$quickForm->addRule("city", "城市不能为空", "required");

$quickForm->addRule("address", "请填写你的联系地址", "required");

$quickForm->addRule("name", "用户登录呢称最少为5个字符", "minlength", 5);

$quickForm->addRule("pass", "密码太简单,不能少于5位", "minlength", 5);

$quickForm->addRule(array("pass", "repass"), "两次的密码不一致", "compare");

$quickForm->addRule("email", "请输入正确的EMAIL地址(user@domain)", "email");

$quickForm->addRule("idnuber", "证件号码不能少于5位", "minlength", 5);

$quickForm->addRule("i

[1] [2] 下一页

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有