Storage Methods of extjs, PHP, and MySQL

Source: Internet
Author: User

1. Create a database and a Registry CopyCode The 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 Code the code is as follows:

Registration






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 code The 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 code The Code is as follows: Ext. Ajax. Request ({
URL:
Success:
Method:
Failure:
Params:

});

Ext. getcmp (). getform (). getvalues ();
Platform: extjs + PhP eclipse + Apache + mysqladmin + firebug

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.