The quick form in PEAR is used to implement a user registration interface. the specific operation database is not written. Maybe I am not very familiar with it. I didn't find its advantages, but it is not as good as JS. HTML can be directly written quickly. Perhaps its advantage is that it can control a lot (not the appearance ). The following example shows how to use QuickForm in PEAR to check the user name, EMAIL address format, credential number, and so on. the specific operation database is not written. Maybe I am not very familiar with it. I didn't find its advantages, but it is not as good as JS. HTML can be directly written quickly. Perhaps its advantage is that it can control a lot (not the appearance ). The following example shows how to check the user name, EMAIL address format, credential number, and so on. of course, JavaScript can be used to perform these checks easily. The following is the final result:
Below is the PHP code
/**
* Manual quick form
*
* Quick form manual input skills
* Use QuickForm to complete a user registration page (including the information review function)
* @ Author jxyuhua at gmail.com
*/
Require_once ("HTML/QuickForm. php ");
Echo (" ");
$ QuickForm = new HTML_QuickForm ("registerFrm ");
$ Country = array ("1" => "China ",
"2" => "Japan ",
"3" => "USA ",
"4" => "UK ",
"0" => "other ");
$ City = array ("1" => "Beijing ",
"2" => "Guangdong ",
"3" => "Jiangxi ",
"0" => "other ");
$ Industry = array ("1" => "student ",
"2" => "scientific research institutions ",
"3" => "IT industry ",
"0" => "other ");
$ From = array ("1" => "Internet Cafe ",
"2" => "unit ",
"3" => "home ",
"0" => "other ");
$ QuickForm-> setDefaults (array ("idtype" => 1,
"Secret" => 1 ));
$ QuickForm-> addElement ("header", null, "new user registration ");
$ QuickForm-> addElement ("text", "name", "What about user logon:", array ("size" => 20, "maxlength" => 20 ));
$ QuickForm-> addElement ("password", "pass", "password:", array ("size" => 20, "maxlength" => 20 ));
$ QuickForm-> addElement ("password", "repass", "repeated password input:", array ("size" => 20, "maxlength" => 20 ));
$ QuickForm-> addElement ("text", "email", "EMAIL address:", array ("size" => 20, "maxlength" => 50 ));
$ QuickForm-> addElement ("text", "passquestion", "password prompt:", array ("size" => 50, "maxlength" => 50 ));
$ QuickForm-> addElement ("text", "passanswer", "password prompt answer:", array ("size" => 50, "maxlength" => 50 ));
$ QuickForm-> addElement ("text", "alias", "What about Chinese users:", array ("size" => 30, "maxlength" => 50 ));
$ QuickForm-> addElement ("textarea", "description", "personal description:", array ("rows" => 3, "cols" => 50, "class" => "textBox "));
$ Radio [] = & $ quickForm-> createElement ("radio", null, null, "the following information is not public", "1 ");
$ Radio [] = & $ quickForm-> createElement ("radio", null, null, "the following information is publicly available", "0 ");
$ QuickForm-> addGroup ($ radio, "secret ");
//? How do I set the default ID card?
// Set the default value for the intermediate method
$ QuickForm-> addElement ("text", "idnuber", "credential number:", array ("size" => 30, "maxlength" => 30 ));
$ Radio2 [] = $ quickForm-> createElement ("radio", "idtype", null, "ID card", null, array ("value" => 1, "checked" => "true "));
$ Radio2 [] = $ quickForm-> createElement ("radio", "idtype", null, "other creden", null, array ("value" => 2 ));
$ QuickForm-> addGroup ($ radio2 );
$ QuickForm-> addElement ("text", "realname", "real name:", array ("size" => 20, "maxlength" => 30 ));
$ QuickForm-> addElement ("select", "gender", "gender:", array ("male" => "male ", "female" => "female "));
$ QuickForm-> addElement ("date", "born", "born in:", array ("format" => "Y, m, d ", "minYear" => 1940, "maxYear" => 1995 ));
$ QuickForm-> addElement ("select", "country", "country:", $ country );
$ QuickForm-> addElement ("select", "city", "Province (city):", $ city );
$ QuickForm-> addElement ("text", "town", "City (county):", array ("size" => 20, "maxlength" => 20 ));
$ QuickForm-> addElement ("text", "address", "contact address:", array ("size" => 50, "maxlength" => 50 ));
$ QuickForm-> addElement ("text", "zipcode", "Zip Code:", array ("size" => 20, "maxlength" => 20 ));
$ QuickForm-> addElement ("text", "phone", "Contact number:", array ("size" => 20, "maxlength" => 20 ));
$ QuickForm-> addElement ("text", "company", "unit:", array ("size" => 30, "maxlength" => 30 ));
$ QuickForm-> addElement ("text", "department", "department:", array ("size" => 20, "maxlength" => 20 ));
$ QuickForm-> addElement ("select", "industry", "industry:", $ industry );
$ QuickForm-> addElement ("select", "source", "where is the main
Visit our website: ", $ from );
$ QuickForm-> addElement ("text", "webpage", "personal homepage:", array ("size" => 50, "maxlength" => 50 ));
$ QuickForm-> addElement ("submit", null, "registered user ");
// Set the form rules
$ QuickForm-> applyFilter ("name", "trim ");
$ QuickForm-> addRule ("name", "the user logon nickname is required !! "," Required ");
$ QuickForm-> addRule ("pass", "password cannot be blank", "required ");
$ QuickForm-> addRule ("email", "EMAIL cannot be blank", "required ");
$ QuickForm-> addRule ("passquestion", "enter a password to indicate a problem", "required ");
$ QuickForm-> addRule ("passanswer", "enter the password and prompt the answer", "required ");
$ QuickForm-> addRule ("idnuber", "enter your ID number", "required ");
$ QuickForm-> addRule ("realname", "enter your real name", "required ");
$ QuickForm-> addRule ("gender", "gender cannot be blank", "required ");
$ QuickForm-> addRule ("born", "birthdate cannot be blank", "required ");
$ QuickForm-> addRule ("country", "country cannot be blank", "required ");
$ QuickForm-> addRule ("city", "city cannot be blank", "required ");
$ QuickForm-> addRule ("address", "enter your contact address", "required ");
$ QuickForm-> addRule ("name", "user logon is called at least five characters", "minlength", 5 );
$ QuickForm-> addRule ("pass", "the password is too simple, not less than five characters", "minlength", 5 );
$ QuickForm-> addRule (array ("pass", "repass"), "two passwords are inconsistent", "compare ");
$ QuickForm-> addRule ("email", "enter the correct EMAIL address (user @ domain)", "email ");
$ QuickForm-> addRule ("idnuber", "the ID number cannot be less than five characters", "minlength", 5 );
$ QuickForm-> addRule ("idnuber", "the document number can only be English letters or numbers"