Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // securing information and storing variables
- $fullname = htmlentities($_REQUEST["fullname"]);
- $username = htmlentities($_REQUEST["username"]);
- $email = htmlentities($_REQUEST["email"]);
- $password = htmlentities($_REQUEST["password"]);
- $phone = htmlentities($_REQUEST["phone"]);
- //if GET or POST are empty
- if(empty($fullname) || empty($username) || empty($email) || empty($password) || empty($phone)){
- $returnArray["status"] = "wrong";
- $returnArray["message"] = "some fields are empty";
- echo json_encode($returnArray);
- return;
- }
- 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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement