|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
学会了生成静态网页,现在你应该接触一下XML了,恩,XML也了解了,那么AJAX你也得接触接触吧?AJAX完了....然后... 用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("idnuber", "证件号码只能是英文字母或数字"
我的文章不会对您的学习起到实质性的作用,您能否成功,还得靠自己的,坚持,坚持,再坚持,就是步入成功的不二法门。 |
|