I try to only be able to post one data only, and only the username data can not password. Could you please help me?????
func onlinecheckin(){
    self.password.resignFirstResponder()
    let password1 = password.text;
    if let user1 = user.text {
        let username = user1.trimmingCharacters(in: CharacterSet.whitespaces)
        let passwordnya = password1!.trimmingCharacters(in: CharacterSet.whitespaces)
        //Send user data to server side
        let myUrl = URL(string: "http://login.php")
        let request = NSMutableURLRequest(url: myUrl!);
        request.httpMethod = "POST"
        let postString = "user=\(username)"
        let postString2 = "password=\(passwordnya)"
        //To upload any text at the server.
        request.httpBody = postString2.data(using: String.Encoding.utf8)
        request.httpBody = postString.data(using: String.Encoding.utf8)
        task = URLSession.shared.dataTask(with: request as URLRequest) {data, response, error in
            print("response online checking =\(String(describing: response))")
            if error != nil {
                task.cancel()
                self.AlertMessage("Error. Please press Login button again.");
                print("error=\(String(describing: error))")
                return
            }
            // Print out downloaded data.
            if let datadownload = data {
                resultlogin = NSString(data: datadownload, encoding: String.Encoding.utf8.rawValue)!.replacingOccurrences(of: " ", with: "");
                print("result of online checking:\(resultlogin)")
            }
            DispatchQueue.main.async(execute: { () -> Void in
                if resultlogin.contains("already") {
                    let secondViewController = self.storyboard?.instantiateViewController(withIdentifier: "menu") as! bdemenu                                   self.navigationController?.pushViewController(secondViewController, animated: true)
                } else {
                    self.AlertMessage("User dan Password Salah");
                }
            })
        }
        task.resume()
    }
}
I try to only be able to post one data only, and only the username data can not password. Could you please help me?????
 
    