Connecting swift to php ... problem

For my school’s project I’ve been working with iOS app and connecting it to mySQL database using php and phpmyadmin. I’ve created php file and successfully linked to the iOS app. The signUp process is working fine but I’ve a problem with the verification of username and password for log in process. I’ve included my code and the part where i need help with swift.

(I couldn’t figure out the swift coding part for login verifications with the database… i got correct results form the php file tho…as in the screenshot)

Please HELP !!!

here’s the code
// For Login

            @IBOutlet weak var Uname: UITextField!
            @IBOutlet weak var Pword: UITextField!
            var a="a" ,r=0
            @IBAction func LogIn(_ sender: Any) {
                
                //put the link of the php file here. The php file connects the mysql and swift
                        let request = NSMutableURLRequest(url: NSURL(string: "http://192.168.64.2/tryLogin.php")! as URL)
                        request.httpMethod = "POST"
                         let postString = "a=\(Uname.text!) & b=\(Pword.text!) "
                        
                        
                        request.httpBody = postString.data(using: String.Encoding.utf8)
                
                        let task = URLSession.shared.dataTask(with: request as URLRequest) {
                            data, response, error in
                            
                            if error != nil {
                                print("error=\(String(describing: error))")
                                
                                return
                            }
                            else{
                               
                            //print("response = \(String(describing: response))")
                            
                            let responseString = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)
                                self.a=(String(describing: responseString))
                                print(self.a)
                               
                                
                            }
                        
                        }
                        task.resume()
                
               
// I NEED HELP FROM DOWN HERE ->
                    // if the username and password is correct
                if (   ){
                    let alertController = UIAlertController(title: "Candidate", message: "Logged In", preferredStyle: UIAlertController.Style.alert)
                    alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default,handler: nil))
                            
                            self.present(alertController, animated: true, completion: nil)
                }
                 
                    // if the username and password is incorrect
                else{
                        let alertController = UIAlertController(title: "Candidate", message: "Incorrect info.", preferredStyle: UIAlertController.Style.alert)
                        alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default,handler: nil))
                                
                                self.present(alertController, animated: true, completion: nil)
                }
                   
            }
        }

Thanks anyways I got the solution:

@IBOutlet weak var Uname: UITextField!
    @IBOutlet weak var Pword: UITextField!
    var a="a" ,r=0
    @IBAction func LogIn(_ sender: Any) {
        
        //put the link of the php file here. The php file connects the mysql and swift
                let request = NSMutableURLRequest(url: NSURL(string: "http://192.168.64.2/tryLogin.php")! as URL)
                request.httpMethod = "POST"
                 let postString = "a=\(Uname.text!) & b=\(Pword.text!) "
                
                
                request.httpBody = postString.data(using: String.Encoding.utf8)
        
        let task = URLSession.shared.dataTask(with: request as URLRequest) { [self]
                    data, response, error in
                    
                    if error != nil {
                        print("error=\(String(describing: error))")
                        
                        return
                    }
                   
                                        
                    
                       
                    //print("response = \(String(describing: response))")
                    
                    let responseString = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)
                        self.a=(String(describing: responseString))
                        print(self.a)
            
            DispatchQueue.main.async {
            if (self.a=="Optional(Success)"){
                // if the username and password is correct
         
                let alertController = UIAlertController(title: "Candidate", message: "Logged In", preferredStyle: UIAlertController.Style.alert)
                alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default,handler: nil))
                        
                        self.present(alertController, animated: true, completion: nil)

                    }
            else{
                    let alertController = UIAlertController(title: "Candidate", message: "Incorrect info.", preferredStyle: UIAlertController.Style.alert)
                    alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default,handler: nil))
                            
                            self.present(alertController, animated: true, completion: nil)
            }
            }
                       
                        
                    
                
                }
                task.resume()
        }

Hi I’m just starting with Swift, I have programmed before with Python and I am still getting my head around all this new UI. I have an app in mind that also needs to connect to a mySQL DB vis PHP, it looks like you have the access part sorted, could you share the full code for the connection, registration and login please? I simply have to make a secure connection to the backend, upload 23 variables a day and download a small table to put into a graph. Many thanks if you can… Geoff