Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 带Mysql的swift 3_Php_Mysql_Swift3 - Fatal编程技术网

Php 带Mysql的swift 3

Php 带Mysql的swift 3,php,mysql,swift3,Php,Mysql,Swift3,我正在尝试用mysql在swift3中注册 但是有点不对劲, 当我运行我的应用程序并使register return msg“某些字段为空”时 在php代码中: $fullname = htmlentities($_REQUEST["fullname"]); $username = htmlentities($_REQUEST["username"]); $email = htmlentities($_REQUEST["email"]); $password = htmlentities($_R

我正在尝试用mysql在swift3中注册 但是有点不对劲, 当我运行我的应用程序并使register return msg“某些字段为空”时

在php代码中:

$fullname = htmlentities($_REQUEST["fullname"]);
$username = htmlentities($_REQUEST["username"]);
$email = htmlentities($_REQUEST["email"]);
$password = htmlentities($_REQUEST["password"]);
$phone = htmlentities($_REQUEST["phone"]) 
swift代码:

let  config = URLSessionConfiguration.default
let  session = URLSession(configuration: config)
let url = URL(string: "http://localhost/php/register.php?")
var request = URLRequest(url: url!)

request.httpMethod = "POST"

let body = "fullname=\(FirstName.text)%20\(LastName.text)&username=\(UserName.text)&email=\(Email.text)&password=\(Password.text)&phone=\(Phone.text)"

request.httpBody = body.data(using: String.Encoding.utf8)

let task = session.dataTask(with: url!) {data, response, error in

if error != nil {
 print(error!.localizedDescription)

} else {

 do {

if let json = try JSONSerialization.jsonObject(with: data!, options: .allowFragments) as? [String: Any]

   {

 print(json)

    }

} catch {
     print("error in JSONSerialization")
     }     

   }      

}
task.resume()

我想你错过了这个

let task = session.dataTask(with: request) {data, response, error in

url
替换为
request

我想你错过了这个

let task = session.dataTask(with: request) {data, response, error in

url
替换为
request

请使用
$\u POST
而不是
$\u request
,这只是一个安全提示;第二,能否将
$\u POST
记录在php文件中:
文件内容('log.txt',json_encode($\u POST,json_PRETTY_PRINT))$\u POST
而不是
$\u REQUEST
,这只是一个安全提示;第二,能否将
$\u POST
记录在php文件中:
文件内容('log.txt',json_encode($\u POST,json_PRETTY_PRINT))并告诉我们您得到了什么