Sencha touch 构建Sencha Touch 2登录系统

Sencha touch 构建Sencha Touch 2登录系统,sencha-touch,extjs,sencha-touch-2,Sencha Touch,Extjs,Sencha Touch 2,我正在尝试使用Sencha Touch 2构建一个多登录系统,用户必须选择他是代理还是追随者。到目前为止,我已经能够提出一个简单的登录表单。没有功能。我的代码如下所示: Ext.define("ikhlas.view.login", { extend: 'Ext.Panel', xtype: 'loginpanel', config:{ title: 'Login', iconCls: 'more', styleHtmlContent:

我正在尝试使用Sencha Touch 2构建一个多登录系统,用户必须选择他是代理还是追随者。到目前为止,我已经能够提出一个简单的登录表单。没有功能。我的代码如下所示:

Ext.define("ikhlas.view.login", {
extend: 'Ext.Panel',
xtype: 'loginpanel',

    config:{
        title: 'Login',
        iconCls: 'more',
        styleHtmlContent: true,

    layout:{
        type: 'vbox',

        },

    items: [
        {
       xtype: 'fieldset',
       iconCls: 'add',

    items: [

        {
            xtype: 'emailfield',
            name: 'email',
            placeHolder: 'Username'
        },

        {
            xtype: 'passwordfield',
            name: 'password',
            placeHolder: 'Password'
        },

        {
            xtype: 'selectfield',
            label: 'User Type',
            options: [
            {text: 'Agent',  value: '0'},
            {text: 'Follower', value: '1'}
            ]
        }

   ]},
        {
            xtype: 'button',
            text: 'LogIn',
            ui: 'confirm',
            width: '40%',
            height: '7%',
            flex: 1,
            left: '55%',
            action: 'submitContact'
        },
        {
            xtype: 'button',
            text: 'Forgot Username',
            ui: 'confirm',
            width: '41%',
            height: '4%',
            top: '90%',
            flex: 1,
            action: 'ForgotUsername'   
        },
        {
            xtype: 'button',
            text: 'Forgot Password',
            ui: 'confirm',
            width: '40%',
            height: '4%',
            top: '90%',
            flex: 1,
            left: '47%',
            action: 'ForgotPassword'  
        },
    ]}
});

现在我想知道如何从API(将给出url)验证用户信息(用户名和密码),以便在允许他们访问应用程序之前确认登录用户名和密码是否正确。其次,如果用户名或密码不正确,我想抛出一条错误消息

很明显,您必须对服务器端进行身份验证。假设你已经有了一个,那么剩下的就不难了

最简单的方法就是发送
Ext.Ajax.request

Ext.Ajax.request({
        url: your_API_url,
        params: {
                       username: your_username_from_formpanel, 
                       password: your_password_from_formpanel
                    },
        timeout: 10000, // time out for your request

        success: function(result) {
                      // here, base on your response, provide suitable messages
                      // and further processes for your users
        },

        failure: function(){
            Ext.Msg.alert("Could not connect to server.");
        }   
    });

注意:出于安全原因,您应该在将用户密码发送到服务器之前对其进行加密。

您将使用什么服务器端语言?您好Thiem Nguyen,感谢您的回复,目前我还没有对服务器端进行身份验证,您是否可以帮我编写一个PHP脚本进行身份验证。第二,我如何加密密码?帮我写一些脚本。如果可能的话,我需要一个可以处理SQL注入的脚本,以便使应用程序不可破解或降低整个应用程序的安全性。非常感谢。我的数据库名将是:ikhlas,表将是ikalas_logs