Extjs Form: Change Password
In the previous tutorial: Login Extjs-Confirm Password , when a user has successfully logged in, then he will go to this page. In this page a user can change his password because there is a session id to identify its.
OK.. this is the screen shot of this tutorial

The following are some of the files you need to create this tutorial.
1. Create php file
session_start();
include "koneksi.php";
if($_SESSION['name']=='')
{
header("location: index.html");
}
?>
2. Create javascript file
Ext.onReady(function(){
Ext.QuickTips.init();
// Create a variable to hold our EXT Form Panel.
// Assign various config options as seen.
var login = new Ext.FormPanel({
labelWidth:130,
url:'changepswd.php',
frame:true,
title: 'please',
collapsible:true,
width:320,
autoHeight:true,
bodyStyle: 'padding: 10px 10px 0 20px;',
padding:200,
modal: true,
defaultType:'textfield',
monitorValid:true,
// Specific attributes for the text fields for username / password.
// The "name" attribute defines the name of variables sent to the server.
items:[{
fieldLabel:'Old Password',
name:'OldPassword',
inputType: 'password',
allowBlank:false
},{
fieldLabel:'New Password',
name:'NewPassword',
inputType:'password',
allowBlank:false
}],
buttons:[{
text:'Save',
handler:function(){
login.getForm().submit({
method:'POST',
waitTitle:'Please wait.......',
waitMsg:'Send data...',
success:function(){
Ext.Msg.alert('Status', 'success bro.......!', function(btn, text){
login.getForm().reset();
});
},
failure:function(form, action){
if(action.failureType == 'server'){
obj = Ext.util.JSON.decode(action.response.responseText);
Ext.Msg.alert('Chage Password!', obj.errors.reason);
}else{
Ext.Msg.alert('Warning!', 'Authentication server is unreachable : ' + action.response.responseText + "abcd");
}
login.getForm().reset();
}
});
}
},
{
text: 'Reset',
handler:function()
{
login.getForm().reset();
}
}]
});
var createwindow = new Ext.Window({
frame:true,
title:'Change Password',
width:330,
height:250,
closable: false,
items: login
});
createwindow.show();
});
3. Create php file
include "koneksi.php";
session_start();
$oldpassword = $_POST["OldPassword"]; ;
$newpassword = $_POST["NewPassword"];
$query = "select password from formlogin where password='$oldpassword'";
$sql = mysql_query($query);
$ada = mysql_fetch_row($sql);
if($ada>1){
$query = "update formlogin set password='$newpassword' where id_user = '".$_SESSION['id']."'";
$sql = mysql_query($query);
echo "{success: true}";
} else {
echo "{success: false, errors: { reason: 'change password failur...' }}";
}
?>
Some other file, you can read here: Login Extjs-Confirm Password
Tags: Attribute, Attributes, Authentication Server, Buttons, Chage Password, Config Options, Failure, Handler Function, Header Location, Location Index, Login, Msg, Password, Password Protection, Reason, Security, Session Id, Session Name, True Title, True Width, Variables, Window Frame
Mas Faisal,
saya dah coba salah satu sample update password.
ada kendala nih
pas klik SAVE, responnya loading ‘Send Data’ terus-terusan n ga mau show message alert nya.
Tapi Data ke Update.
knapa ya ???