title: Weirdness when data POST to PHP script
body: <p>I am using the following code to post data from an android app to a PHP script:</p>
  
  <pre><code>public class Upload extends Activity implements OnClickListener {
  EditText joke;
  Button upload = (Button) findViewById(R.id.bUpload);
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.upload);
      upload.setOnClickListener(this);
  }
  public void onClick(View v) {
      // TODO Auto-generated method stub
      switch (v.getId()) {
      case R.id.bUpload:
          uploadJoke();
          break;
      }
  
  }
  private void uploadJoke() {
      // Create a new HttpClient and Post Header
      HttpClient httpclient = new DefaultHttpClient();
      HttpPost httppost = new HttpPost("http://xxxx/telejoke.php");
  
      try {
          // Add your data
          List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2);
          nameValuePairs.add(new BasicNameValuePair("username", "test"));
          nameValuePairs.add(new BasicNameValuePair("joke", joke.getText().toString()));
          httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
  
          // Execute HTTP Post Request
          HttpResponse response = httpclient.execute(httppost);
  
      } catch (ClientProtocolException e) {
      } catch (IOException e) {
      }
  }
  </code></pre>
  
  <p>This code sends data to a PHP script, which then sends it on to an SQL database. This data shows up in the SQL database, but if I try something like <code>echo $username</code> it doesn't show the username when I go to <a href="http://xxxx/telejoke.php" rel="nofollow">http://xxxx/telejoke.php</a>.</p>
  
  <p>PHP script:</p>
  
  <pre><code>&lt;?php
    include 'DBConnect.php';
    include 'JokeValidate.php';
  
    $username = $_POST['username'];
    $joke = $_POST['joke'];
    $dbname = 'Telejoke';
    mysql_select_db($dbname);
  
    echo $username. " " . $joke;
  
    if (validate()){
      $query = "INSERT INTO jokes (username, joke) VALUES ('$username','$joke')";
      mysql_query($query) or die('Error, insert query failed');
    }
    mysql_close($conn);
  ?&gt;
  </code></pre>
  
  <p>Please help. I want to do things to the posted data with PHP besides just send it on to database.</p>