2

my view contains the following code

this.keypadDisplay = Ext.create('Ext.field.Text', {
            xtype:'textfield',
            disabled: true,
            value: ''
        });

my ajax request code is

handler: function(b, e) {
                    var thisUser = this.getValue();
                   alert(thisUser);
                    //params[this.getSubmitParamName()] = this.getValue();
                    Ext.Ajax.request({
                        url:'http://localhost/sencha2011/keypadapp/code.php',
                        params: thisUser,
                        method:'GET',
                        success: function(response, opts){
                            var text = response.responseText;
                            console.log(response.responseText);
                            alert(thisUser);
                            //alert(this.getValue());
                            //alert('Value: ' + this.getValue());
                            Ext.Msg.alert('success', text);
                        },
                        failure: function(response, opts){
                            Ext.Msg.alert('Error','Error while submitting the form');
                            console.log(response.responseText);
                           },
                        scope: this
                    });
            }

here i'm getting the "this.getValue" successfully. i want to insert to this.getValue to the code table. my code.php contains the following code

<?php
$con = mysql_connect("localhost","root","");
mysql_select_db('form',$con);

$insert = "INSERT INTO codetable(password) VALUES ('".$_GET['thisUser.value']."')";

if(mysql_query($insert))
{
    echo('values inserted successfully');
}
else
{
    echo('failure' . mysql_error());
}
?>

here im getting the error as "Undefined index:thisUser.Value in .../keypadapp/code.php " on line 5. can anyone help me to ? thanks in advance...

jimmy
  • 37
  • 1
  • 6

2 Answers2

0

Try changing $_GET['thisUser.value'] to $_GET['thisUser_value'] dots in $_GET and $_POST get converted to underscores in PHP. See this for more info https://stackoverflow.com/a/68742/589909

Update

Looking closer at your code you can't get javascript values of an object in php like you are doing. I assume that thisUser is an object. So when passing it as a param its properties will be posted to the server individually. So if it had a property called foo you would get it like so. $_GET['foo']; also you could dump the get request to see what was sent. var_dump($_GET);

Community
  • 1
  • 1
brenjt
  • 15,997
  • 13
  • 77
  • 118
0

Assign param value to variable in ajax call:

                Ext.Ajax.request({
                    url:'http://localhost/sencha2011/keypadapp/code.php',
                    params: 'thisuser='+thisUser,

Then in php, access the value:

$insert = "INSERT INTO codetable(password) VALUES ('".$_GET['thisuser']."')";
Karan Punamiya
  • 8,603
  • 1
  • 26
  • 26