Login Extjs: Confirm Password
In this section i want to share how to make simple login form using extjs as client-side and php as server-side and mysql as the database, login form is very important to protect website from hacker attacks, login form can also be used to controlling user access rights to access web pages.
Here i created login form that has the following feature:
1. Confirm password
This is a code to make validation vtype confirm password
Ext.apply(Ext.form.VTypes, {
password : function(val, field)
{
if (field.initialPassField) {
var login = Ext.getCmp(field.initialPassField);
return (val == login.getValue());
}
return true;
},
passwordText : 'Passwords do not match' //alert if you enter a password that is not the same
});
and this is code to make field.
{
fieldLabel:'Password',
name:'password',
width:190,
inputType:'password',
id: 'pass',
allowBlank:false
},
{
fieldLabel:'Confirm Password',
name:'password1',
width:190,
inputType:'password',
vtype:'password',
initialPassField: 'pass',
allowBlank:false
}
look that code, in fieldLabel:’Password’ => must have “id” this was used as reference on the confirm password, this is the code initialPassField: ‘pass’, and dont forget to add vtype:’password’ in confirm password.
2. Session username
$_SESSION['name']=$name;
3. Redirected if success login.
if (btn == 'ok')
{
var redirect = 'admin.php';
window.location = redirect;
}
4. Protect from sql injection.
$name = stripslashes(trim($_POST["username"]));
$password = stripslashes(trim($_POST["password"]));
$query = sprintf("select * from formlogin where username='%s' and password='%s'", mysql_real_escape_string($name),mysql_real_escape_string($password));
5. Logout.
download source code
http://www.ziddu.com/download/9410352/login.zip.html

Interesting blog, I like the font.