我正在尝试使用创建一个简单的表单ExtJS
并将值发送到数据库中,但它不会将我输入的值插入到我的表单中。我不知道为什么它不将数据输入数据库。我不知道我的代码有什么问题......任何人都可以帮助我实现我想要做的事情。
感谢高级家伙
PS即时使用Extjs 5
//我的Extjs
表格
Ext.define('Grid.view.main.Form', {
extend: 'Ext.form.Panel',
xtype:'form',
title: 'User Form',
id:'myformpanel',
height: 120,
width: '100%',
autoScroll:true,
defaults: {
xtype: 'textfield',
labelAlign: 'top',
padding: 10
},
layout: {
type: 'hbox'
},
items: [{
fieldLabel: 'TEST1',
name: 'Test1'
},{
fieldLabel: 'TEST2',
name: 'Test2'
},{
fieldLabel: 'TEST3',
name: 'Test3'
},{
fieldLabel: 'TEST4',
name: 'Test4'
},{
fieldLabel: 'TEST5',
name: 'Test5'
},{
fieldLabel: 'TEST6',
name: 'Test6'
},{
fieldLabel: 'TEST7',
name: 'Test7'
},{
fieldLabel: 'TEST8',
name: 'Test8'
},{
fieldLabel: 'TEST9',
name: 'Test9'
},{
fieldLabel: 'TEST10',
name: 'Test10'
},{
fieldLabel: 'TEST11',
name: 'Test11'
},{
fieldLabel: 'TEST12',
name: 'Test12'
},
],
buttons: [{
text: 'login',
name:'submit',
handler: function(){
Ext.Ajax.request({
url: 'data/testform.php',
method: 'POST',
params: Ext.getCmp('myformpanel').getForm().getFieldValues(),
success: function(response){
Ext.Msg.alert('success ' + response.status);
},
failure: function(response){
Ext.Msg.alert('server-side failure with status code ' + response.status);
}
});
}
});
}
}]
//testform.php
<?php
require_once('database_connection.php');
if(isset($_POST['submit'])){
$Test1=$_POST['Test1'];
$Test2=$_POST['Test2'];
$Test3=$_POST['Test3'];
$Test4=$_POST['Test4'];
$Test5=$_POST['Test5'];
$Test6=$_POST['Test6'];
$Test7=$_POST['Test7'];
$Test8=$_POST['Test8'];
$Test9=$_POST['Test9'];
$Test10=$_POST['Tes10t'];
$Test11=$_POST['Test11'];
$Test12=$_POST['Test12'];
$query="INSERT INTO testexcel (Test1,Test2,Test3,Test4,Test5,Test6,Test7,Test8,Test9,Test10,Test11,Test12) VALUES ('$Test1','$Test2','$Test3','$Test4','$Test5','$Test6','$Test7','$Test8','$Test9','$Test10','$Test11','$Test12')";
}
?>