title: Call Php from Swift 3 iOS
body: <p>Hello I have update my old swift app in the new version of swift 3, The code was connected to a php page by passing values ​​in post and then returning a json message since I updated the app to swift 3 xcode me from the following errors, How can i fix these errors?</p>
  
  <p><strong>Error:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/LdryK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LdryK.png" alt="enter image description here"></a></p>
  
  <p><strong>Swift Code:</strong></p>
  
  <pre><code>let URL_SAVE_TEAM = "http://localhost/ios-login.php"
      var email:String = "";
      var password:String = "";
  
  
      func PrintValue(){
  
         // print(username);
          //print(password);
      }
  
      func Login() -&gt; Bool{
  
  
          //created NSURL
          let requestURL = NSURL(string: URL_SAVE_TEAM)
  
          //creating NSMutableURLRequest
          let request = NSMutableURLRequest(URL: requestURL)
  
          //setting the method to post
          request.HTTPMethod = "POST"
  
          //getting values from text fields
  
  
          //creating the post parameter by concatenating the keys and values from text field
          let postParameters = "email="+email+"&amp;password="+password;
  
          //adding the parameters to request body
          request.HTTPBody = postParameters.dataUsingEncoding(NSUTF8StringEncoding)
  
  
          //creating a task to send the post request
          let task = NSURLSession.sharedSession().dataTaskWithRequest(request){
              data, response, error in
  
              if error != nil{
                  print("error is \(error)")
                  return;
              }
  
              //parsing the response
              do {
                  //converting resonse to NSDictionary
                  let myJSON =  try NSJSONSerialization.JSONObjectWithData(data!, options: .MutableContainers) as? NSDictionary
  
                  //parsing the json
                  if let parseJSON = myJSON {
  
                      //creating a string
                      var msg : String!
  
                      //getting the json response
                      msg = parseJSON["message"] as! String?
  
                      //printing the response
                      print(msg)
  
  
  
                  }
              } catch {
                  print(error)
              }
  
          }
          //executing the task
          task.resume()
  
          return false;
      }
  </code></pre>
  
  <p><strong>Xcode Image of Error:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/RPNk1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RPNk1.png" alt="enter image description here"></a></p>
  
  <p><strong>PHP CODE:</strong></p>
  
  <pre><code>&lt;?php
  
      header('Content-Type: application/json');
      $email= $_POST['email'];
      $password = $_POST['password'];
      $ris='Ti rispondo dal server zio';
  
     echo json_encode($ris);
    //  echo "prova";
  
  ?&gt;
  </code></pre>