PHP PearHTMLQuickForm implements user registration form interface

xiaoxiao2021-03-06  42

Using QuickForm in PEAR to implement a user registered interface, the specific operation database is not written. Maybe I am still not very skilled, I didn't find its advantages, but it was not as good as JS, and HTML was written directly. Perhaps it is the advantage of being able to control a lot (not an appearance). The following example is realized

User name, Email address format check, document number, etc., of course, these JS can be done easily, everyone will see the benevolence.

Below is the final rendering:

Below is a PHP code

/ ** * Quickform handmade * * Quickform hand-input skilled articles * complete a user registration page with Quickform (including information review) * @Author jxyuhua at gmail.com * / request_once ('html / quickform.php'

); Echo (' "

$ Quickform = New HTML_QUICKFORM ('registerfrm'

$ Country = array ('1' => "China"

, '2' => 'Japan'

, '3' => 'US'

, '4' => 'UK'

, '0' => 'Other'

$ City = array ('1' => "Beijing"

, '2' => 'Guangdong'

, '3' => 'Jiangxi'

, '0' => 'Other'

$ Industry = array ('1' => 'student'

, '2' => 'research institution'

, '3' => 'IT Industry'

, '0' => 'Other'

$ From = array ('1' => "Internet cafes"

, '2' => 'unit'

, '3' => 'home'

, '0' => 'Other'

$ QuickForm-> setDefaults (array ('idtype' => 1

, 'Secret' => 1); $ Quickform-> AddElement ('header', null, 'new user registration "

$ Quickform-> addelement ('text', 'name ",' user login, said: ', array (' size '=> 20,' maxlength '=> 20

$ Quickform-> addelement ('password', 'pass', 'password:', array ('size' => 20, 'maxlength' => 20

))); $ Quickform-> addelement ('password', 'repass ",' repeated input password: ', array (' size '=> 20,' maxlength '=> 20

)); $ Quickform-> addelement ('text', 'email', 'email address:', array ('size' => 20, 'maxlength' => 50

)); $ Quickform-> addelement ('text', 'passquestion', 'password prompt problem:', array ('size' => 50, 'maxlength' => 50

))); $ Quickform-> addelement ('text', 'passanswer', 'password prompt answer:', array ('size' => 50, 'maxlength' => 50

)); $ Quickform-> addelement ('text', 'alias ",' user Chinese, said: ', array (' size '=> 30,' maxlength '=> 50

))); $ Quickform-> addelement ('Textarea', 'Description ",' personal description information: ', array (' rows' => 3, 'cols' => 50,' Class' => 'TextBox'

)))); $ Radio [] = & $ Quickform-> CreateElement ('Radio', NULL, NULL, "The following information is not open", '1'

$ Radio [] = & $ Quickform-> CreateElement ('Radio', NULL, NULL, "The following information is open", '0'

$ Quickform-> AddGroup ($ RADIO, 'Secret');

/ /? How to set the next way to the ID card? //, set the default value $ quickform-> addelement ('text', 'idnuber', 'document number:', array ('size' => 30, ' Maxlength '=> 30

); $ Radio2 [] = $ radio, ',' i dPE ', null,' identity card, null, array ('value' => 1, 'checked' => 'True'

))); $ Radio2 [] = $ radio, ',' r d dPE ', NULL,' Other Documents', 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 month M month 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', 'Postal Code:', Array ('size' => 20, 'Maxlength' => 20); $ Quickform-> AddElement ('Text' , 'phone', 'contact number:', array ('size' => 20, 'maxlength' => 20

)); $ Quickform-> addelement ('Text', 'Company', ') Office:', 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 key
Access our website: ', $ from

$ Quickform-> addelement ('Text', 'WebPage', 'Person Home:', Array ('size' => 50, 'Maxlength' => 50

))))); $ Quickform-> AddElement ('Submit', Null, 'Registered User'

);

/ / Set the rules of the form $ Quickform-> Applyfilter ('Name', 'Trim'

$ Quickform-> addrule ('name ",' user login nickname must be filled out !! ',' Required '

$ Quickform-> addrule ('pass', 'password can't be empty', 'Required'

$ Quickform-> addrule ('email', 'email Email can't be empty ",' Required '

$ Quickform-> addrule ('passquestion', "please fill in the password prompt problem ',' Required '

$ Quickform-> Addrule ('passanswer', "please fill in the password prompt answer ',' Required '

$ Quickform-> AddRule ('IDNuber', 'Please fill in the ID number', 'Required'

$ Quickform-> Addrule ('RealName', 'Please fill in the real name "); $ quickform-> addrule (' gender ',' gender can't be empty", 'Required'

$ Quickform-> addrule ('born', 'Birth dates can not be empty', 'Required'

$ Quickform-> AddRule ('Country', 'Country Can't empty ",' Required '

$ Quickform-> addrule ('city', 'city can't be empty ",' Required '

$ Quickform-> addrule ('address', "please fill in your contact address',' Required '

); $ Quickform-> addrule ('name ",' user login, is the least 5 characters', 'MINLENGTH', 5

$ Quickform-> addrule ('pass',' The password is too simple, can not be less than 5 ", 'minlength', 5

); $ Quickform-> addrule (array ('pass',' repass'), 'two passwords are inconsistent,' Compare '

$ QuickForm-> addrule ('email', "Please enter the correct email address (user @ domain), 'email'

); $ Quickform-> addrule ('IDNuber', 'ID number can not be less than 5 ",' minlength ', 5

$ Quickform-> AddRule ('IDNuber', "The ID number can only be English letters or numbers', 'alphaumeric'

$ Quickform-> Registerrule ('Keyword', 'Function', 'Checkuser "

$ QuickForm-> addrule ('name', 'username already exists, please re-select', 'keyword'

);

// Change Style $ HeadeRTemplate

= <<< HTML

{header}

HTML; $ formTemplate

= <<< html

>

{content}

HTML; $ ElementTemplate

= <<< HTML

* {label}

} Else {$ Quickform-> Display

();} Function Exportvalues ​​($ DATA

) {ECHO ('

'

PRINT_R ($ DATA

ECHO (''

} Function Checkuser ($ ElementName, $ ElementValue

) {$ Keywords = array ('admin', 'administrator', 'Webmaster', 'Supervisor'

); If (In_Array ($ ElementValue, $ Keywords

)) {RETURN FALSE

} Else {return true

}}

?>

CSS file:

TD {font-size: 9pt; font-family: arial; line-height: 150%; color: # 333333;

.table1 {

Background: #fffff;

}

.td7 {

Background: # ffd04f;

}

.td8 {

Background: #efefcf;}

.td9 {

Background: # d9d98e;

}

.TextBox {

Border: 1PX Solid # 989c67;

Background-color: #fffff;

ScrollBar-Face-Color: # dee3e7;

Scrollbar-highlight-color: #fffff;

Scrollbar-shadow-color: # dee3e7;

Scrollbar-3DLight-Color: # d1d7dc;

Scrollbar-arrow-color: # 006699;

Scrollbar-track-color: #efefef;

Scrollbar-Darkshadow-Color: # 98aab1;

}

转载请注明原文地址:https://www.9cbs.com/read-54748.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.046, SQL: 9