1 Establish database, registry
Copy Code code as follows:
Create Database Db_register;
CREATE TABLE Db_register.tb_register (
Reg_loginid varchar () primary key,
Reg_name varchar is not NULL,
reg_id int NOT NULL,
Reg_password varchar is not NULL,
Reg_sex varchar (2),
reg_address varchar (50)
);
2 Establishment of register.php and save.php
register.php Call ExtJS File
save.php Data storage
Register.php=>
Copy Code code as follows:
<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>
<body>
</body>
Save.php=>
Copy Code code as follows:
<?php
if ($_post[' password ']!=$_post[' Repassword '))
{
Do not perform 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 "registered successfully";
}
Else
{
echo "Registration failed";
}
Mysql_close ($conn);
?>
3 ExtJS file register.js written
Register.js=>
Copy Code code as follows:
Ext.onready (function () {
function Registerhandler () {
var values = ext.getcmp ("form"). GetForm (). GetValues (); Get TextField, radio equivalents in 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: ' Login account: '
},{
X:80,
y:0,
Name: ' Login ',
Anchor: ' 100% '
},{
x:0,
Y:30,
Xtype: ' label ',
Text: ' User name: '
},{
X:80,
Y:30,
Name: ' Name ',
Anchor: ' 100% ',
},{
x:0,
Y:60,
Xtype: ' label ',
Text: ' ID number: '
},{
X:80,
Y:60,
Name: ' ID ',
Anchor: ' 100% ',
},{
x:0,
Y:90,
Xtype: ' label ',
Text: ' User password: '
},{
X:80,
Y:90,
InputType: ' Password ',
Name: ' Password ',
Anchor: ' 100% ',
},{
x:0,
Y:120,
Xtype: ' label ',
Text: ' Password confirmation: ',
},{
X:80,
Y:120,
Name: ' Repassword ',
InputType: ' Password ',
Anchor: ' 100% ',
},{
X:80,
y:150,
Xtype: ' Radio ',
Name: ' Sex ',
Fieldlabel: ' Sex ',
Boxlabel: ' Male ',
Inputvalue: ' B '//radio value is: b
},{
x:0,
y:152,
Xtype: ' label ',
Text: ' Sex: '
},{
x:140,
y:150,
Xtype: ' Radio ',
Name: ' Sex ',
Fieldlabel: ' Sex ',
Boxlabel: ' Female ',
Inputvalue: The value of ' G '//radio is: g
},{
x:0,
y:180,
Xtype: ' label ',
Text: ' User address '
},{
X:80,
y:180,
Name: ' Address ',
Anchor: ' 100% '
}]
});
var window = new Ext.window ({
Title: ' Registered account ',
width:400,
HEIGHT:300,
minwidth:400,
MINHEIGHT:300,
Layout: ' Fit ',
Plain:true,
Bodystyle: ' padding:5px; ',
Buttonalign: ' Center ',
Items:form,
Buttons: [{
Text: ' Register ',
Handler:registerhandler
},{
Text: ' Cancel '
}]
});
Window.show ();
});
4 Running http://localhost/register/register.php
5 Input relevant information, click ' Register '
6 Post Aspect
7 Database aspects
8 Summary
Ext.window
Buttons's Handler
The value Inputvalue of radio
Copy Code code as follows:
Ext.Ajax.request ({
Url:
Success
Method
Failure:
Params:
});
EXT.GETCMP (). GetForm (). GetValues ();
Platform: extjs+php eclipse+apache+mysqladmin+firebug