1. Create a database and a Registry
Copy codeThe Code is as follows:
Create database db_register;
Create table db_register.tb_register (
Reg_loginid varchar (20) primary key,
Reg_name varchar (20) not null,
Reg_id int not null,
Reg_password varchar (20) not null,
Reg_sex varchar (2 ),
Reg_address varchar (50)
);
2. Create register. php and save. php.
Register. php calls ExtJS File
Save. php Data Storage
Register. php =>
Copy codeThe Code is as follows:
<Html>
<Head>
<Title> Registration </title>
<Link rel = "stylesheet" type = "text/css" href = "../ext/resources/css/ext-all.css"/>
<Script type = "text/javascript" src = "../ext/adapter/ext/ext-base.js"> </script>
<Script type = "text/javascript" src = "../ext/ext-all.js"> </script>
<Script type = "text/javascript" src = "register. js"> </script>
</Head>
<Body>
</Body>
</Html>
Save. php =>
Copy codeThe Code is as follows:
<? Php
If ($ _ POST ['Password']! = $ _ POST ['repassword'])
{
// Do not execute storage
Exit;
}
$ Conn = mysql_connect ("localhost", "root", "123 ");
Mysql_select_db ("db_register ");
$ SQL = "insert into tb_register (reg_loginid, reg_name, reg_id, reg_password, reg_sex, reg_address)
Values ('". $ _ POST ['login']. "','". $ _ POST ['name']. "','". $ _ POST ['id']. "','". $ _ POST ['Password']. "','"
. $ _ POST ['sex']. "','". $ _ POST ['address']. "')";
If (mysql_query ($ SQL, $ conn ))
{
Echo "registration successful ";
}
Else
{
Echo "registration failed ";
}
Mysql_close ($ conn );
?>
3 ExtJs file register. js
Register. js =>
Copy codeThe Code is as follows:
Ext. onReady (function (){
Function registerhandler (){
Var values = Ext. getCmp ("form"). getForm (). getValues (); // obtain the textfield and radio values in the form.
Ext. Ajax. request ({
Url: 'save. php ',
Success: function () {Ext. Msg. alert ("success ");},
Method: "post ",
Failure: function () {Ext. Msg. alert ("failure ");},
Params: values
});
}
Var form = new Ext. form. FormPanel ({
Id: 'form ',
BaseCls: 'x-plain ',
Layout: 'absolute ',
Url: 'save-form. php ',
DefaultType: 'textfield ',
Items :[{
X: 0,
Y: 0,
Xtype: 'label ',
Text: 'logon account :'
},{
X: 80,
Y: 0,
Name: 'login ',
Anchor: '000000'
},{
X: 0,
Y: 30,
Xtype: 'label ',
Text: 'user name :'
},{
X: 80,
Y: 30,
Name: 'name ',
Anchor: '20140901 ',
},{
X: 0,
Y: 60,
Xtype: 'label ',
Text: 'id No :'
},{
X: 80,
Y: 60,
Name: 'id ',
Anchor: '20140901 ',
},{
X: 0,
Y: 90,
Xtype: 'label ',
Text: 'user password :'
},{
X: 80,
Y: 90,
InputType: 'Password ',
Name: 'Password ',
Anchor: '20140901 ',
},{
X: 0,
Y: 120,
Xtype: 'label ',
Text: 'Confirm password :',
},{
X: 80,
Y: 120,
Name: 'repassword ',
InputType: 'Password ',
Anchor: '20140901 ',
},{
X: 80,
Y: 150,
Xtype: 'Radio ',
Name: 'sex ',
FieldLabel: 'gender ',
BoxLabel: 'male ',
InputValue: 'B' // The value of radio is B.
},{
X: 0,
Y: 152,
Xtype: 'label ',
Text: 'gender :'
},{
X: 140,
Y: 150,
Xtype: 'Radio ',
Name: 'sex ',
FieldLabel: 'gender ',
BoxLabel: 'femal ',
InputValue: 'G' // radio value: g
},{
X: 0,
Y: 180,
Xtype: 'label ',
Text: 'user address'
},{
X: 80,
Y: 180,
Name: 'address ',
Anchor: '000000'
}]
});
Var window = new Ext. Window ({
Title: 'register account ',
Width: 400,
Height: 300,
MinWidth: 400,
MinHeight: 300,
Layout: 'fit ',
Plain: true,
BodyStyle: 'padding: 5px ;',
ButtonAlign: 'center ',
Items: form,
Buttons :[{
Text: 'registration ',
Handler: registerhandler
},{
Text: 'cancel'
}]
});
Window. show ();
});
4. Run http: // localhost/register. php
5. Enter relevant information and click Register'
6 Post
7. Database
8. Summary
Ext. Window
Handler of buttons
Radio value: inputValue
Copy codeThe Code is as follows:
Ext. Ajax. request ({
Url:
Success:
Method:
Failure:
Params:
});
Ext. getCmp (). getForm (). getValues ();
Platform: ExtJS + PHP Eclipse + Apache + MySQLadmin + firebug