Tim Johnstone
Tim Johnstone

Reputation: 363

How do I post variables from Flash Builder 4.6 and get the result in PHP? Any Ideas?

I'm rather new to Flash Builder but I've read some articles on the web and on here and it's a persistent problem that I just can't seem to solve.

In Flash Builder, I have a search bar with an ID of 'searchBar'. Along with the search bar there's a button labelled 'Submit'.

How my system works is this:

  1. I have set up a HTTP Service:

      <s:HTTPService id="searchBookAuthor"
                   url="http://localhost/cm0665-assignment/web/libraryServicePipe.php"
                   result="searchBookAuthor_resultHandler(event)"
                   fault="libraryService_faultHandler(event)"
                   method="POST"
                   >
    
        <s:request xmlns="">
            <searchBar>{searchBar.text}</searchBar>
        </s:request>
    
    </s:HTTPService>
    
  2. User enters a search term in the search box and clicks 'Submit'
  3. When the button is clicked, a click_handler event is called, and within here I have made a variable:

     var param:Object = new Object;
                param.action = 'search';
                searchBookAuthor.send(param); // ID of HTTPService
    


3. The action = 'search' relates to a case function in my PHP server side file.

My problem is that I dont know how to get the data that the user enters to be picked up in PHP. I have this but it doesn't work (though I've tested the script by passing the URL some parameters):

$searchValue = $_POST["searchBar"];

                $recset = new T_XMLRecordSet();

                $searchSQL = "select Title, Author from l_stock WHERE Title OR Author LIKE '%$searchValue%'";

                $result = $recset ->getRecordSet($searchSQL, 'book');
                return $result; 

And the result returns every Title and Author in my database and $_POST['searchBar'] doesn't seem to getting the data. Sorry it's a lot to look at it but I really don't know where I'm going wrong.

Any help is greatly appreciated, Thanks.

Tim

Upvotes: 0

Views: 928

Answers (1)

mask8
mask8

Reputation: 3638

Edit a little bit your request structure:

<s:request xmlns="">
    <searchBar>{searchBar.text}</searchBar>
    <action>search</action>
</s:request>

then in click_handler event:

searchBookAuthor.send()

This should work.

*When you are passing param to send() function, you are basically overwriting your request structure. In other word, you can also do it in this way:

var param:Object = new Object;
            param.action = 'search';
            param.searchBar = searchBar.text;
            searchBookAuthor.send(param);

Upvotes: 1

Related Questions