Note that there are some explanatory texts on larger screens.

plurals
  1. PO$_POST variable doesn't work in php Titanium
    primarykey
    data
    text
    <p>I'm trying to pass data between a JS file and a PHP file, but the variable <code>$_POST</code> in PHP doesn´t work and for that i can´t evolve in the app!</p> <p>JS code:</p> <pre class="lang-js prettyprint-override"><code>var params = String(input.value); var xhr = Titanium.Network.createHTTPClient(); xhr.open('GET','http://10.0.2.2/jobfinder/teste_demo_grafica/Resources/teste.php'); xhr.send(params); xhr.onload = function(){ var response = this.responseText; alert(response); if (response != null) { alert("voltou ao js e funca"); } else { alert("-.-"); } }; xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); xhr.onerror = function(e){alert('Transmission error: ' + e.error);}; }); </code></pre> <p>and now the php code:</p> <pre class="lang-php prettyprint-override"><code>&lt;?php // Connect to the database(host, username, password) $con = mysql_connect('localhost','root',''); if (!$con) { return ("Failed to make connection."); exit; } // Select the database. Enter the name of your database (not the same as the table name) $db = mysql_select_db('jobfinder'); if (!$db) { echo "Failed to select db."; exit; } $pesquisa= $_POST[params]; echo "pesquisa"; $sql = "SELECT * FROM oferta WHERE titulo like '%$pesquisa%'"; $query = mysql_query($sql); if (mysql_num_rows($query) &gt; 0) { $row = mysql_fetch_array($query); $response = array( 'titulo' =&gt; $row['titulo'], 'oferta' =&gt; $row['descricao_oferta'] ); json_encode($response); echo $response['titulo']; } else { // Else the username and/or password was invalid! Create an array, json_encode it and echo it out $response = array( 'message' =&gt; 'Não existem ofertas para esta pesquisa' ); json_encode($response); } echo "php mode off"; ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload