Simple Post Request with Alamofire

457 views Asked by At

It's my first post here, I'm trying to do this with Alamofire:

Swift code:

let name = "Taza"
let description = "50cl"
let parameters = ["name": name, "description": description]

Alamofire.request(.POST, "http://xxxxx.es/JSONpresenter.php?op=5", parameters: parameters, encoding: .JSON);

PHP code:

$op=$_GET['op'];

else if($op == 5)
{

    // Get user id
    $name = isset($_POST['name']) ? mysql_real_escape_string($_POST['name']) : “”;
    $description = isset($_POST['description']) ? mysql_real_escape_string($_POST['description']) : “”;

    add($name,$description);

}

But only get a register with "" in all cells. What am I doing wrong?

1

There are 1 answers

0
pipizanzibar On

You need to use the URLEncoding instead of JSONEncoding for this particular case