alright, I will re-explain everything from the beginning

Context : I am developing a personal application portal, in which I
want to add various application made in GWT. This portal will run on a
php server.
For this, I began with the identication module, so I have a database
'user' with two fields 'name' and 'pass' on my php server.

What I want is to use php to check that the user exists in the
database. Here is my php script :
      <?php
      // Here we call JSON.php
      require_once("JSON.php");

      // Then we do the query to the MySQL DB, and fetch the results
      $conector = mysql_connect("localhost", "root", "") or
die(mysql_error());
      mysql_select_db('portail') or die(mysql_error());

      $name = $_GET['name'];
      $pwd =$_GET['pwd'];
      $name = stripslashes($name);

      $sqlQuery = "SELECT name FROM user WHERE name = $name AND passe
= $pwd";
      $dataReturned = mysql_query($sqlQuery) or die(mysql_error());
      $i = 0;

      while($row = mysql_fetch_array($dataReturned)){

      // We fill the $value array with the data.
       $value{"item"}{$i}{"nom"}= $row['nom'];
       $i++;
      }

      // We use JSON.php for convert the data to JSON format and send
it to the browser
      $json = new Services_JSON();
      $output = $json->encode($value);
      print($output);
      ?>

For calling this script from gwt, I use this code, which (I think)
should call my php script through the RequestBuilder :

        public void checkPass(String pass){
                String url = "authenticate.php?name=\'RamI\'&pwd=\'"+pass+"\'";
                System.out.println(url); // to be sure that the url is correct
                RequestBuilder requestBuilder = new
RequestBuilder( RequestBuilder.GET, url );
                try {
                        requestBuilder.sendRequest( null, new RequestCallback(){

                                public void onError(Request request, Throwable 
exception) {
                                        System.out.println("Unable to make the 
query "+ request);
                                }

                                public void onResponseReceived(Request request, 
Response
response){
                                        System.out.println(response.getText()); 
// check what is
the response
                                        final JSONValue jsVal =
JSONParser.parse(response.getText());
                                        final JSONArray jsonNews =
jsVal.isObject().get("item").isArray();

                                        
if(!jsonNews.isArray().get(0).isObject().equals(null)){
                                                Portail.doSomething();
                                        }else{
                                                Window.alert("error");
                                        }
                                }
                        } );
                } catch (RequestException e) {
                        System.out.println(e.toString());
                }
        }

What I am waiting is that "response.getText()" gives me the result of
my php script, interpreted. Instead I get the whole script, from <?php
to ?>

So I am saying that the PHP script works when submitted directly in a
browser, but not in hosted mode in my GWT App, and also not when the
code is compiled.
If I try to parse the String {"item":[{"name":"usernameTest"}]}
instead of response.getText() in my onResponseReceived method, the
program works as I expect. Moreover, if I submit the php script in a
browser, this string is the one I get !

My local Apache server is the one included in easyPhP, but I tried
different versions.

RamI
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to