close

register.php

<html>
<head>
<title></title>
    <link rel="stylesheet" type="text/css" href="../ext-3.2.1/resources/css/ext-all.css" />
    <script type="text/javascript" src="../ext-3.2.1/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="../ext-3.2.1/ext-all.js"></script>
    <script type="text/javascript" src="register.js"></script>
</head>
<body>
</body>
</html>

register.js

Ext.onReady(function() {
    function registerhandler(){
        var values = Ext.getCmp("form").getForm().getValues();        //護取form裡textfield、radio等值
        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: '登錄帳戶:'
        },{
            x: 80,
            y: 0,
            name:'login',
            anchor:'100%'  
        },{
            x: 0,
            y: 30,
            xtype:'label',
            text: '用户姓名:'
        },{
            x: 80,
            y: 30,
            name:'name',
            anchor: '100%',  
        },{
            x:0,
            y:60,
            xtype:'label',
            text:'身份证号:'
        },{
            x:80,
            y:60,
            name:'id',
            anchor:'100%',
        },{
            x:0,
            y:90,
            xtype:'label',
            text:'用户密码:'
        },{
            x:80,
            y:90,
            inputType:'password',
            name:'password',
            anchor:'100%',
        },{
            x:0,
            y:120,
            xtype:'label',
            text:'密码确认:',
        },{
            x:80,
            y:120,
            name:'repassword',
            inputType:'password',
            anchor:'100%',
        },{
            x:80,
            y:150,
            xtype:'radio',
            name:'sex',
            fieldLabel:'性别',
            boxLabel:'男',
            inputValue:'b'                //radio的取值为:b
        },{
            x:0,
            y:152,
            xtype:'label',
            text:'性别:'
        },{
            x:140,
            y:150,
            xtype:'radio',
            name:'sex',
            fieldLabel:'性别',
            boxLabel:'女',
            inputValue:'g'                //radio的取值为:g
        },{
            x:0,
            y:180,
            xtype:'label',
            text:'用户住址'
        },{
            x:80,
            y:180,
            name:'address',
            anchor:'100%'
        }]
    });

    var window = new Ext.Window({
        title: '註册帐户',
        width: 400,
        height:300,
        minWidth:400,
        minHeight: 300,
        layout: 'fit',
        plain:true,
        bodyStyle:'padding:5px;',
        buttonAlign:'center',
        items: form,
        buttons: [{
            text: '註册',
            handler:registerhandler
        },{
            text: '取消'
        }]
    });

    window.show();
});

save.php

<?php
if($_POST['password']!=$_POST['repassword'])
{
//不执行存储
    exit;
}

$conn=mysql_connect("localhost","dbname","passwd");
mysql_select_db("dbname");

$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 "注册成功";
}
else
{
    echo "注册失败";
}
mysql_close($conn);
?>

arrow
arrow
    全站熱搜

    塵封等待 發表在 痞客邦 留言(3) 人氣()