PDA

View Full Version : Formpanel to PHP



drabslab
9 Aug 2009, 6:27 AM
Hai, I have a ridicoulous problem but I can't find the solution :-/

I have a FormPanel which submits data to a PHP page with a "myform.getForm.submit()"

I manage to make the PHP page send a message to the server that the ajax submit was successful with an "echo {success: true}"

but I can not figure out how to access the data sent by the Formpanel in the php page.

$_POST and $_GET do not seem to work

The only example that I can find on this site is in an apparently corrupted zip file.

could someone spare a minute to point this clumsy newbie to a working example?:((:((

Animal
9 Aug 2009, 6:37 AM
"myForm.getForm.submit()" won't actually submit anything (It will throw a javascript error) , so I'm not sure I believe you that you are getting your PHP server to see anything,.

Submitting a form submits in a perfectly normal format with HTTP parameters.

drabslab
9 Aug 2009, 7:01 AM
the whole story looks like this:

var storyform = new Ext.FormPanel({
url: 'controller.php?cdrv=3',
layout: 'form',
bodyStyle:'padding:2px;',
tbar: [{
text: 'Save',
handler: function() {
storyform.getForm().submit ({
waitMsg:'Sending data to server...',
success: function(f,a) {
Ext.Msg.alert('success', 'Data succesfully sent');
storyform.getForm().reset();
},
failure: function (f,a) {
Ext.Msg.alert('Warning', 'error');
}
});
}
},{
text: 'Reset',
handler: function() {
storyform.getForm().reset();
}
}],
items: [{
xtype: 'textfield',
fieldLabel: 'Title',
name: 'title'
},{
xtype: 'textfield',
fieldLabel: 'Summary',
name: 'summary'
},{
xtype: 'htmleditor', // should be htmleditor, only for testing purposes
id: 'bulk',
fieldLabel: 'Bulk',
name: 'bulk',
defaultValue: 'enter your text here',
height: 300,
anchor: '98%'

}]
});

then I have a toolbar in a window which opens the storyform


tbar: [{
text: 'New story', // introducing a new family story
handler: function () {
var storyformwindow = new Ext.Window ({
layout: 'fit',
plain:true,
title: 'New story',
width: 600,
closable: true,
closeAction:'hide',
items: storyform
});
storyformwindow.show()
}
}],


Now, when i click on the submit button i first get the 'sending data to server' message

and a bit later, after the server (the php page "controller.php?cdrv=3") has answered with the {success: true} echo I reccieve the alert 'data successfully sent'

From this I think that the content of the formpanel is actually sent to the server.

What I can't find is how the php page can access the received info.

I find a lot of info on this site how to send data to the server, but absolutely nothing how a php page on the server can access that data and do something with it

steffenk
9 Aug 2009, 7:03 AM
please edit your post and use code boxes!

drabslab
9 Aug 2009, 7:07 AM
if i would know what code boxes are i would most cetainly do so :-((

drabslab
9 Aug 2009, 7:10 AM
the whole story looks like this:









var storyform = new Ext.FormPanel({






url: 'controller.php?cdrv=3',
layout: 'form',
bodyStyle:'padding:2px;',


tbar: [{

text: 'Save',
handler: function() {
storyform.getForm().submit ({
waitMsg:'Sending data to server...',
success: function(f,a) {
Ext.Msg.alert('success', 'Data succesfully sent');
storyform.getForm().reset();
},
failure: function (f,a) {
Ext.Msg.alert('Warning', 'error'); }
});
}
},{
text: 'Reset',
handler: function() {
storyform.getForm().reset();}
}],
items: [{
xtype: 'textfield',
fieldLabel: 'Title',
name: 'title'
},{
xtype: 'textfield',
fieldLabel: 'Summary',
name: 'summary'
},{
xtype: 'htmleditor', // should be htmleditor, only for testing purposes
id: 'bulk',
fieldLabel: 'Bulk',
name: 'bulk',
defaultValue: 'enter your text here',
height: 300,
anchor: '98%'}]});
then I have a toolbar in a window which opens the storyform










tbar: [{
text: 'New story', // introducing a new family story
handler: function () {
var storyformwindow = new Ext.Window ({
layout: 'fit',
plain:true,
title: 'New story',
width: 600,
closable: true,
closeAction:'hide',
items: storyform
});storyformwindow.show()
}
}],


Now, when i click on the submit button i first get the 'sending data to server' message

and a bit later, after the server (the php page "controller.php?cdrv=3") has answered with the {success: true} echo I reccieve the alert 'data successfully sent'

From this I think that the content of the formpanel is actually sent to the server.

What I can't find is how the php page can access the received info.

I find a lot of info on this site how to send data to the server, but absolutely nothing how a php page on the server can access that data and do something with it
b

drabslab
9 Aug 2009, 7:13 AM
please edit your post and use code boxes!

I honestly tried to give my post a good layout using the buttons above the input field but it does not work, yet another problem :(

steffenk
9 Aug 2009, 7:25 AM
wrong button! use #, result: [ code]...[ /code]

drabslab
9 Aug 2009, 7:31 AM
thanks, i tried, it is slightly better

i do not think that the problem is in the ext code, i just do nto know what i have to do on the receiving end withPHP

I thought that i could get to the sent data by using (as example)

$test = $_POST('summary');

but as soon as i do that I get an 7636 syntax error in the browser

Animal
9 Aug 2009, 7:46 AM
In the browser?

You are supposed to be submitting data and processing it on the server in the normal PHP way.

There is no such thing as a "7636" error.

Your PHP is wrong.

drabslab
9 Aug 2009, 7:55 AM
I know my php is wrong (at least i think that i do)

my problem is what to do about it

is the formpanel submitting a json file, or a xml or...?
should i use $_POST or $_GET on the php side

these may seem stupid questions (and they probably are) but for a newbie like me it proves very difficutl to find the answer

drabslab
9 Aug 2009, 8:02 AM
In the browser?

You are supposed to be submitting data and processing it on the server in the normal PHP way.

There is no such thing as a "7636" error.

Your PHP is wrong.

no actually it is a syntax error on line 7636 which is in the json encode part of the ext code.

I assume as well that the error is on the php side

The kind of questions that i need an answer to:

- is formpanel submitting data as json, xml or anything else
- should i use $_POST or $_GET on the php side

these may all be quite dummy questions but for a newbie it seems very difficult to find the answers to this anywhere. The information on this site concentrates almost entirely on receiving data from a server, not on how a server can access sublitted data from ext.

steffenk
9 Aug 2009, 9:59 AM
you don't know how arrays are read in php???
$_POST['value']

you should read some beginner tutorial first.

drabslab
10 Aug 2009, 1:29 AM
you don't know how arrays are read in php???
$_POST['value']

you should read some beginner tutorial first.


I know quite a bit of PHP, that is not the problem.

At least you confirm now that a $_POST['value'] should do the trick. That is what I was thinking and I have tried that already.

The problem is that it does not work and $_GET and all the other things that i can think of do not work either.

I expected that the Ext field with name 'title' would be available in php with $_POST['title']. Is that assumption not correct?

steffenk
10 Aug 2009, 1:52 AM
why not debug it?

echo 'POST: <pre>' . print_r($_POST, true) . '</pre>';