I am trying to create a simple form using ExtJS
and send the value into database, but it doesn't insert what I enter value into my form. I don't know why it doesn't input the data into database.
PS: I am using Extjs 5
My Extjs
form:
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')";
}
?>
Thanks Sir @Hown_ for helping me... i figure out what is the problem why isnt insert my data into database... because of my database is wrong configuration so this my code
//my extjs form panel
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);
}
});
}]
});
//my testform.php
<?php
require_once('database_connection.php');
$Test1= isset($_POST['Test1']) ? $_POST['Test1'] : NULL;
$Test2= isset($_POST['Test2']) ? $_POST['Test2'] : NULL;
$Test3= isset($_POST['Test3']) ? $_POST['Test3'] : NULL;
$Test4= isset($_POST['Test4']) ? $_POST['Test4'] : NULL;
$Test5= isset($_POST['Test5']) ? $_POST['Test5'] : NULL;
$Test6= isset($_POST['Test6']) ? $_POST['Test6'] : NULL;
$Test7= isset($_POST['Test7']) ? $_POST['Test7'] : NULL;
$Test8= isset($_POST['Test8']) ? $_POST['Test8'] : NULL;
$Test9= isset($_POST['Test9']) ? $_POST['Test9'] : NULL;
$Test10= isset($_POST['Test10']) ? $_POST['Test10'] : NULL;
$Test11= isset($_POST['Test11']) ? $_POST['Test11'] : NULL;
$Test12= isset($_POST['Test12']) ? $_POST['Test12'] : NULL;
$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')";
mysql_query($query,$con);
?>
Hope this code will help the beginner like me....
Thanks