Evaluating bids

Aprendendo a programar

Published on the June 27, 2016 in IT & Programming

About this project

Open

Estou com essa função para cadastrar um usuario no banco de dados MYSQL, e não esta funcionando e não aparece erro algum? estou usando o Xcode e MYSQL.
   
    @IBAction func Grava(sender: AnyObject){
       
       
       
        let userNome = txtNome.text;
        let userEmail = txtEmail.text;
        let userSenha = txtSenha.text;
       
        // check for empty fields
        if (userNome!.isEmpty || userEmail!.isEmpty || userSenha!.isEmpty)
           
        {
           
            // display alert message
            //displayMyAlertMessage("All fields are required");
            return;
        }


       
        // Send user data to server-side
        let myUrl = NSURL(string: "http://localhost/userRegister.php");
       
        let request = NSMutableURLRequest(URL: myUrl!);
        request.HTTPMethod = "POST";
        let postString = "nome=\(userNome)&email=\(userEmail)&password=\(userSenha)";
        request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding);
       
        let task = NSURLSession.sharedSession().dataTaskWithRequest(request){
            data, response, error -> Void in
           
            if (error != nil){
                print("error=\(error)")
                return
            }
           
            do{
               
                let json = try NSJSONSerialization.JSONObjectWithData(data!, options:
                    NSJSONReadingOptions.AllowFragments) as! NSDictionary
               
                print("json: \(json)");
               
                let resultValue = json["status"] as! String;
                print("Result: \(resultValue)")
               
                var isUserRegistered:Bool = false;
               
                if(resultValue=="Success"){
                    isUserRegistered = true;
                }
               
                var messageTodisplay:String = json["message"] as! String;
               
                if(!isUserRegistered){
                    messageTodisplay = json["message"] as! String;
                }
               
                dispatch_async(dispatch_get_main_queue(), {
                   
                    let myAlert = UIAlertController(title: "Alert", message:
                        messageTodisplay, preferredStyle: UIAlertControllerStyle.Alert);
                   
                    let okaction = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil);
                   
                    myAlert.addAction(okaction);
                   
                    self.presentViewController(myAlert, animated:true, completion:nil);
                })
               
            }catch let error as NSError{
                print(error)
            }
        }
        task.resume();


    }

Category IT & Programming
Subcategory Apps programming. Android, iOS and others
Is this a project or a position? Project
I currently have I have an idea
Required availability As needed
Experience in this type of projects No (I haven’t managed this kind of project before)
Required platforms iPhone, iPad, Android

Delivery term: Not specified