title: Xcode 8.3 get data from php and json
body: <p>I'm trying to make a small program, that send a username to a web data base. and get the name, status, point of the user.
  i have fund out how to send the username, and get the json output.
  it look like this: {"name":"gert","status":"0","point":"20"}
  and this is my php code</p>
  
  <pre><code>&lt;?php
  header('Content-type: application/json');
  ob_start();
  session_start();
  mysql_connect("host","username","password");
  mysql_select_db("dbname") or die("Unable to select database");
  
  $qrcode = $_POST['username'];
  
  
  $result = mysql_query("SELECT * FROM qrcode WHERE qrcode = '$qrcode' ");
  $pic_name = mysql_fetch_array($result);
  
  $myObj = new \stdClass();
                  $myObj-&gt;name = $pic_name['name'];
                  $myObj-&gt;status = $pic_name['status'];
                  $myObj-&gt;point = $pic_name['point'];
  
                  $myJSON = json_encode($myObj);
  
                  echo $myJSON;
  
  ob_end_flush();
  ?&gt;
  </code></pre>
  
  <p>and this is my swift code</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
  let url_to_request:String = "http://www.hholm.dk/time_app/gertqrcode.php"
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      download_request()
  
        }
  
  func download_request()
  {
      let url:URL = URL(string: url_to_request)!
      let session = URLSession.shared
  
      let request = NSMutableURLRequest(url: url)
      request.httpMethod = "POST"
      request.cachePolicy = NSURLRequest.CachePolicy.reloadIgnoringCacheData
  
      let paramString = "username=200"
      request.httpBody = paramString.data(using: String.Encoding.utf8)
  
  
      let task = session.downloadTask(with: request as URLRequest, completionHandler: {
          (
          location, response, error) in
  
  
          let urlContents = try! NSString(contentsOf: location!, encoding: String.Encoding.utf8.rawValue)
  
          guard let _:NSString = urlContents else {
              print("error")
              return
          }
  
          print(urlContents)
  
  
      }) 
  
      task.resume()
  
  }
  
  
  }
  </code></pre>
  
  <p>and now i have to extract the json, (i think its called)
  I would like to have the name, status and point, as some ting i can use i the rest of the program. </p>