import UIKit class ViewController: UIViewController { let URL_SAVE_BOY = "http://hpscript.com/swift/index.php" @IBOutlet weak var NameFeild: UITextField! @IBOutlet weak var oldFeild: UITextField! @IBAction func saveBtn(_ sender: Any) { let requestURL = NSURL(string: URL_SAVE_BOY) let request = NSMutableURLRequest(url: requestURL! as URL) request.httpMethod = "POST" let teamName = NameFeild.text let memberOld = oldFeild.text let postParameters = "name="+teamName!+"&old="+memberOld!; request.httpBody = postParameters.data(using: String.Encoding.utf8) let task = URLSession.shared.dataTask(with: request as URLRequest){ data, response, error in if error != nil { print("error is \(error)") return; } do { let myJSON = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary if let parseJSON = myJSON { var msg : String! msg = parseJSON["message"] as! String? print(msg) } } catch { print(error) } } task.resume() } override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } }

