Today we will learn Swift PHP MySQL. As while developing applications for mobile we need a server for our database. And for this PHP and MySQL is the best option available as it is easy to use and get. So in this Swift PHP MySQL Tutorial we will learn how we can connect our Xcode Project to an external MySQL Database. If you don’t want to do additional server side scripting for your application’s backend you can go through the Firebase iOS Tutorial, where instead of a server you can use Firebase as you appliation’s backend.
If you are looking for a User Registration using PHP and MySQL Tutorial you can visit it from below link.
iOS User Registration Tutorial using PHP and MySQL
In this post we will create a simple Single View App to store some data in our MySQL Database. I will be using the following tools.
- Xcode 7
- PHP Storm
- Xampp (for PHP and MySQL)
The first thing we need is our database so lets create the database.
Swift PHP MySQL Tutorial – Creating Web Service
We need a web service often called REST API, as a medium of communication between our webserver and iPhone application. So first we will create our Web Service that will handle the database insertion. As the below demonstrated method is not recommended, you should check PHP REST API Tutorial instead. But I wanted to make this tutorial as simple as possible so we are creating the web service in simplest way.
Creating MySQL Database
First we will create the MySQL Database. I have created my database model. Below you can see my database model.
This is our database. Its very small and simple as I wanna make this tutorial as simple as possible. To create the above database follow these steps.
- Go to phpmyadmin (localhost/phpmyadmin) and create a new database.
- Now select the database and execute the following SQL statement.
-- tables -- Table: team CREATE TABLE team ( id int NOT NULL AUTO_INCREMENT, name varchar(20) NOT NULL, member int NOT NULL, CONSTRAINT team_pk PRIMARY KEY (id) ); -- End of file.
- And then you will have a database table like the following.
- Now we have our database. We will store the values in this table.
But the values to be stored here will be sent from our iPhone App. And hence we need a communication medium between this database and our iPhone Application. PHP will do this thing for us. So now we will create our web service using PHP.
Creating PHP Scripts
I am going to use PHP Storm IDE, as I love this IDE. So open PHP Storm (You can also use notepad++ or any other text editor).
- Create a new project in the xampp’s htdocs folder. I have created MyWebService.
- Create two more directories inside your project, as shown in the below image.
- Inside directory includes create a file named Config.php and write the following code. The below code contains important constant that will be used to connect to our database.
<?php /** * Created by PhpStorm. * User: Belal * Date: 12/08/16 * Time: 7:58 PM */ define('DB_USERNAME', 'root'); define('DB_PASSWORD', ''); define('DB_HOST', 'localhost'); define('DB_NAME', 'iphone');
- Now in the same directory (includes) again create a new file named DbConnect.php and write the following code. This file will create the database connection.
<?php class DbConnect { private $conn; function __construct() { } /** * Establishing database connection * @return database connection handler */ function connect() { require_once 'Config.php'; // Connecting to mysql database $this->conn = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME); // Check for database connection error if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // returing connection resource return $this->conn; } }
- We need one more file here for the database operation, create a file DbOperation.php and write the following code.
<?php class DbOperation { private $conn; //Constructor function __construct() { require_once dirname(__FILE__) . '/Config.php'; require_once dirname(__FILE__) . '/DbConnect.php'; // opening db connection $db = new DbConnect(); $this->conn = $db->connect(); } //Function to create a new user public function createTeam($name, $memberCount) { $stmt = $this->conn->prepare("INSERT INTO team(name, member) values(?, ?)"); $stmt->bind_param("si", $name, $memberCount); $result = $stmt->execute(); $stmt->close(); if ($result) { return true; } else { return false; } } }
- Now inside api folder create a file named createteam.php and write the following code. This file will actually insert the values to database.
<?php //creating response array $response = array(); if($_SERVER['REQUEST_METHOD']=='POST'){ //getting values $teamName = $_POST['name']; $memberCount = $_POST['member']; //including the db operation file require_once '../includes/DbOperation.php'; $db = new DbOperation(); //inserting values if($db->createTeam($teamName,$memberCount)){ $response['error']=false; $response['message']='Team added successfully'; }else{ $response['error']=true; $response['message']='Could not add team'; } }else{ $response['error']=true; $response['message']='You are not authorized'; } echo json_encode($response);
- Yeah our web service is ready.
- Now we need to know the IP of your xampp server you can easily get it by using ifconfig command. Open terminal and write ifconfig and hit enter.
- So we have the IP, now we can write the URL of the webservice. The IP we got points to the htdocs folder so my Web Service URL to create a new team is.
http://192.168.1.103/MyWebService/api/createteam.php
Testing our Web Service
Before moving to iOS Application Development we should first test the web service we created. For testing we can use any REST Client. I am using POSTMAN for chrome.
- Open POSTMAN and send a POST request with the required parameters to your service URL. You can see the below image for help.
- As you can see we got the success message. Now you can check you database table.
- Yes our URL is working fine. Now we will send a post request to the URL from our iPhone App to insert values. So lets move ahead to xcode side part.
Swift PHP MySQL Tutorial – Xcode Project
Creating a New Project
We have our web service now, lets start creating our iPhone App project in Xcode.
- Create a Single View App for iPhone in Xcode.
Adding Views
- Now go to your Main.storyboard and drag two Text Fields for name and member count values. You also need to add a Button where we will click to save the added values.
Connecting Views to ViewController
- Now connect the Views to your ViewController.swift file. So the code for your ViewController.swift will be.
// // ViewController.swift // SwiftPHPMySQL // // Created by Belal Khan on 12/08/16. // Copyright © 2016 Belal Khan. All rights reserved. // import UIKit class ViewController: UIViewController { //URL to our web service let URL_SAVE_TEAM = "http://192.168.1.103/MyWebService/api/createteam.php" //TextFields declarations @IBOutlet weak var textFieldName: UITextField! @IBOutlet weak var textFieldMember: UITextField! //Button action method @IBAction func buttonSave(sender: UIButton) { } override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } }
- Now we will make a post request to your web service using NSMutableURLRequest.
Making POST Request to our Web Service
- Now inside the Button action function we will send a POST Request to the URL. For this we will use NSMutableURLRequest.
- So here is the code, I have written the comments to explain the code.
// // ViewController.swift // SwiftPHPMySQL // // Created by Belal Khan on 12/08/16. // Copyright © 2016 Belal Khan. All rights reserved. // import UIKit class ViewController: UIViewController { //URL to our web service let URL_SAVE_TEAM = "http://192.168.1.103/MyWebService/api/createteam.php" //TextFields declarations @IBOutlet weak var textFieldName: UITextField! @IBOutlet weak var textFieldMember: UITextField! //Button action method @IBAction func buttonSave(sender: UIButton) { //created NSURL let requestURL = NSURL(string: URL_SAVE_TEAM) //creating NSMutableURLRequest let request = NSMutableURLRequest(URL: requestURL!) //setting the method to post request.HTTPMethod = "POST" //getting values from text fields let teamName=textFieldName.text let memberCount = textFieldMember.text //creating the post parameter by concatenating the keys and values from text field let postParameters = "name="+teamName!+"&member="+memberCount!; //adding the parameters to request body request.HTTPBody = postParameters.dataUsingEncoding(NSUTF8StringEncoding) //creating a task to send the post request let task = NSURLSession.sharedSession().dataTaskWithRequest(request){ data, response, error in if error != nil{ print("error is \(error)") return; } //parsing the response do { //converting resonse to NSDictionary let myJSON = try NSJSONSerialization.JSONObjectWithData(data!, options: .MutableContainers) as? NSDictionary //parsing the json if let parseJSON = myJSON { //creating a string var msg : String! //getting the json response msg = parseJSON["message"] as! String? //printing the response print(msg) } } catch { print(error) } } //executing the task task.resume() } override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } }
Making changes in Info.plist file
- Now the last important thing is you need to do some changes in your Info.plist file, because we are using Xampp and it is not a secure connection. And by default iPhone App will not allow you to make request on http URLs. So to make it work on http open Info.plist file and add the following at the end. Just before the </dict> tag.
<!-- add from here --> <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> <key>NSExceptionDomains</key> <dict> <key>yourdomain.com</key> <dict> <key>NSIncludesSubdomains</key> <true/> <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> <false/> </dict> </dict> </dict> <!-- end of the code -->
- Now try running your application.
Testing Your Application
- Now the coding part is done. Just run your application in Simulator.
- Fill the values and click on Save Team. And then check Xcode.
- Yeah we got the success message. Now lets check the database.
Bingo! Its working absolutely fine. If you are having troubles you can get my source code from the link given below.
[sociallocker] Swift PHP MySQL Tutorial Source Code (2019 downloads) [/sociallocker]
So thats all for this Swift PHP MySQL Tutorial friends. Feel free to ask if having any doubts or queries with your comments. In the upcoming tutorials I will do some more cool things with Swift PHP MySQL, till then stay tuned. Thank You 🙂
HS says
I have error with this “Error Domain=NSCocoaErrorDomain Code=3840 “JSON text did not start with array or object and option to allow fragments not set.” UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}”
shihab says
I have error with this “Error Domain=NSCocoaErrorDomain Code=3840 “JSON text did not start with array or object and option to allow fragments not set.” UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}”
Jack SI Bellis says
Belal,
Great tutorial. I particularly want to point out that it does something critical that, sadly, the majority of tutorials are getting wrong these days: it includes the barest minimum ingredients to perform the subject matter. When tutorials instead attempt to be “robust” or “realistic” they unintentionally hide the exact learning points that comprise the subject, and make a time-consuming puzzle out of things. There’s nothing wrong with making a robust example or tutorial (or even a more secure one)… but it then is no longer a tutorial of, in this case iOS>PHP>SQL… it is something different.
I also suspect that this particular topic is a very valuable one, so it should be useful to a lot of people. There are only a very few end-to-end tutorials on iOS>db.
Thanks
Jack SI Bellis says
Some minor editing comments, mostly for newer folks, which most tutorial users are likely to be:
-To use Postman, after pasting your url in the Post box, you have to use the Body ‘tab’ and enter the keys for your data.
-The three interface controls need to be connected in the storyboard, not just the code shown in the view controller.
-In the info.plist file replace yourdomain.com either your IP address or perhaps some variant of localhost. For me it worked with “193.01.12.7” or “localhost/” or “localhost\” or “localhost://” but hard to be sure if a value was cached.
Mukta says
how the 3 interface in storyboard will be connected? plz tell me.
Micheal... says
So I tried all of these. I did change your IP with mine of course. “The certificate for this server is invalid. You might be connecting to a server that is pretending to be “number” which could put your confidential information at risk.” Any guidance?
jaksa says
Why this method is not recommended..what should i change in oreder to make code more proffesional or secure?
Andy says
Thanks for helping me as a beginner who can learn by doing quicker.
I tried to compile all the codes you provide to get a feel, but ran into one single error in ViewController.swift shown below.
Code –
//creating NSMutableURLRequest
let request = NSMutableURLRequest(URL : requestURL!)
Error msg –
‘NSURL’ is not implicitly convertible to ‘URL’, did you mean to use ‘as’ to explicitly convert?
BTW, I am using Xcode 8.2.1, MacOS 10.12.3. How should I fix it?
It’d be very appreciated.
using exact code an using Xcode 8.2.1 on MacOS 10.12.3,
Jonathan says
To get it working in Swift 3 do the following
Change this
//URL to our web service
let URL_SAVE_TEAM = “http://192.168.1.103/MyWebService/api/createteam.php”
To this
//URL to our web service
let URL_SAVE_TEAM = URL(string: “http://192.168.1.103/MyWebService/api/createteam.php”)
Remove this line since it is no longer needed
let requestURL = NSURL(string: URL_SAVE_TEAM)
change this line
//setting the method to post
request.HTTPMethod = “POST”
To this
//setting the method to post
request.httpMethod = “POST”
Change this line
//adding the parameters to request body
request.HTTPBody = postParameters.dataUsingEncoding(NSUTF8StringEncoding)
Tho this line
//adding the parameters to request body
request.httpBody = postParameters.data(using: String.Encoding.utf8)
Change this line
//creating a task to send the post request
let task = NSURLSession.sharedSession().dataTaskWithRequest(request){
data, response, error in
To this
//creating a task to send the post request
let task = URLSession.shared.dataTask(with: request as URLRequest){
data, response, error in
Lastly Change This line
//converting resonse to NSDictionary
let myJSON = try NSJSONSerialization.JSONObjectWithData(data!, options: .MutableContainers) as? NSDictionary
To this
//converting resonse to NSDictionary
let myJSON = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary
Jonathan says
One more thing needed is update the following line of code to match the URL we will be calling. Since we deleted the requestURL Variable we can call the URL Directly here.
Change this line
//creating NSMutableURLRequest
let request = NSMutableURLRequest(url: requestURL!)
To this
//creating NSMutableURLRequest
let request = NSMutableURLRequest(url: URL_SAVE_TEAM!)
nany says
i’m using swift3 and i’ve some problem about code was written in swift2
so , i wann ask u about URL?
what did u meant ?
how can i put URL?
where i get it from?
Reem says
thanq for this helpful i realy cant even thank u again , when i’m convert like u i have probelm
;
let myJSON = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary
[the error : use unresolve identifier data]
what i shoul do ?
Mário Santos says
Very good! Solved my problem. thanks
How do I read and show for example the team lists?
thanks
Brian says
Hi there
Please assist
The viewcontroller file does not run with swift3
class ViewController: UIViewController {
//URL to our web service
let URL_SAVE_TEAM = URL(“string: http://192.168.56.1/MyWebService/api/createteam.php“)
//TextFields declarations
@IBOutlet weak var textFieldName: UITextField!
@IBOutlet weak var textFieldMember: UITextField!
//Button action method
@IBAction func buttonSave(sender: UIButton) {
//created NSURL
//let requestURL = NSURL(string: URL_SAVE_TEAM)
//creating NSMutableURLRequest
let request = NSMutableURLRequest(URL: requestURL!)
//setting the method to post
//request.HTTPMethod = “POST”
request.httpMethod = “POST”
//getting values from text fields
let teamName=textFieldName.text
let memberCount = textFieldMember.text
//creating the post parameter by concatenating the keys and values from text field
let postParameters = “name=”+teamName!+”&member=”+memberCount!;
//adding the parameters to request body
//request.HTTPBody = postParameters.dataUsingEncoding(NSUTF8StringEncoding)
request.httpBody = postParameters.data(using: String.Encoding.utf8)
//creating a task to send the post request
let task = URLSession.shared.dataTask(with: request as URLRequest){
data, response, error in
if error != nil{
print(“error is \(error)”)
return;
}
//parsing the response
do {
//converting resonse to NSDictionary
let myJSON = try JSONSerialization.jsonObject(with: data!, options:.mutableContainers) as? NSDictionary
//parsing the json
if let parseJSON = myJSON {
//creating a string
var msg : String!
//getting the json response
msg = parseJSON[“message”] as! String?
//printing the response
print(msg)
}
} catch {
print(error)
}
}
//executing the task
task.resume()
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
They two lines that give me problems:
This
let URL_SAVE_TEAM = URL(“string: http://192.168.56.1/MyWebService/api/createteam.php“)
AND
This
let request = NSMutableURLRequest(URL: requestURL!)
Jonathan says
Change
//URL to our web service
let URL_SAVE_TEAM = URL(“string: http://192.168.56.1/MyWebService/api/createteam.php“)
to this
let URL_SAVE_TEAM = URL(string: “http://192.168.56.1/MyWebService/api/createteam.php“)
You had your apostrophe in the wrong place.
That should fix the first problem.
then change
let request = NSMutableURLRequest(URL: requestURL!)
to this
let request = NSMutableURLRequest(URL: URL_SAVE_TEAM!)
You need pass in the variable holding the URL because it needs a URL link to pass through into this method in order to make the HTTP request.
manpreet says
sir i am getting error in Createteam.php that name and member is undefined in line no 9 and 10
ali says
me to please give a solution
Micheal... says
Ok so I had the same error. This is what I got:
https://stackoverflow.com/questions/4261133/php-notice-undefined-variable-notice-undefined-index-and-notice-undef
Use the checked solution. Basically add the following in the createTeam.php:
$teamName = isset($_POST[‘name’]) ? $_POST[‘name’] : ”;
$teamName = !empty($_POST[‘name’]) ? $_POST[‘name’] : ”;
$memberCount = isset($_POST[‘member’]) ? $_POST[‘member’] : ”;
$memberCount = !empty($_POST[‘member’]) ? $_POST[‘member’] : ”;
Steve says
I was getting the same error and fixed it using this code. I know get the success team created message but when I check my database the name is blank and the member is 0.
It seems like it’s not getting the post string. Any ideas?
David says
There could be a mixed up with how you test the PHP. Tried $_GET instead of $_POST and see if it worked. I had the same problem initially and got the content after using the $_GET method instead.
Luke says
I am having an issue with 2 lines:
let myJSON = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary
Error = Consecutive statements on a line must be separated by ‘;’
} catch {
Error = Expected ‘while’ in ‘do-while’ loop
SIVA says
Hi, i have use xcode 8.3.2 and while i import the url request it shows that error what i shared here, could you please help me to get out of this problem.
ERROR: 1 ‘NSURL’ is not implicitly convertible to ‘URL’; did you mean to use ‘as’ to explicitly convert?
ERROR: 2 ‘NSURLSession’ has been renamed to ‘URLSession’
ERROR: 3 Editor placeholder in source file
Edwin says
When I’m using the postman to check the database it give me an error when using the post. Says Undefined index: name in and Undefined index: member in the createteam.php
Neeru says
yes same err !
Gustavo says
Hi, I’m taking a message:
Error Domain=NSCocoaErrorDomain Code=3840 “JSON text did not start with array or object and option to allow fragments not set.” UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
Frank says
I created another outlet to display the response on the UI. For some reason when the response is already received it take about 7 seconds for the message to display on the View Controller. Any idea why there’s a latency. The php server processed it fast. it the time from once the response mapped to the outlet label.
//getting the json response
msg = parseJSON[“message”] as! String?
self.resp=msg
//printing the response
print(msg)
self.outMsg.text = self.resp //< send response to label field in UI
}
rich1812 says
Hello, I only get to the php part. Instead of getting to the showed screen, on POSTMAN I keep getting this screen:http://www.mobwebplanet.com/phpWebService/mine.png
Why is that? Looks like the $POST never got sent.
Newbe says
What if using mssqlserver as its database, can it?
If you can, can you make the tutorial, thq
Dan says
Very good tutorial – congratulations.
Just one question that I couldn’t find the answer to is:
How is this code to be secured ?? I mean – you do a webpost to a server without any checks on the server side (all credentials are stored on the server side)… Anyone can add items into the db… So – the following question rises – How can I make this secure enough to use it ?
Thanks again,
Best regards
Belal Khan says
You have to use some kind of authentication for server side. You can use a framework like laravel, lumen to build the REST Apis that provides the inbuilt authentication functionalities like OAuth, Basic Auth etc.
Zeb says
Hello
First I would like to say thank you for your amazing tutorials. If possible could you elaborate a bit more on integrating Larval, Lumen, Oauth or a Rest API? I’m building an app to communicate directly with my WP site and insert data in some tables and would like to secure my communications from app to server. I’ve googled searched but unfortunately come up short with a good guide or starting point for doing this. Again thank you and I appreciate any response you may have for a newbie.
Micheal says
Well I keep getting an error of Not Authorized. Not sure what I am doing wrong. I am using MySQL Workbench…
Rich1812 says
Although ther are some good tips in these tutorial. I don’t see the point of going through Postman. It adds an extra layer of and complexity and confusion, and it is neither iOS nor mySq related!
ahmad irfan says
hi!
i have an error on this ={“error”:true,”message”:”Could not add team”}
tell me why?
Belal Khan says
The problem in your php scripts.. check them carefully
Fabio de Paula says
Please Belal….
Send a link with all the files, because we dont see the rest of code.
Thank you so much.
Zeb says
Hi Belal,
Thank you so much for posting this tutorial. It is by far one of the best i’ve found. I’m a very green dev and am getting this error”{“error”:true,”message”:”You are not authorized”}” when using postman or browsing directly to the createteam.php file. I’m sure it is something simple and i’ve gone over my code multiple time but don’t see any errors. I see the error is originating from the else statement in createteam.php but i’m not whats causing it to error. I have looked in the apache2 log and no errors are thrown. I’m using Ubuntu LAMP server for web hosting if you could give me a few pointers or places I might look to resolve this I would greatly appriciate it.
Thanks again for the great tutorial.
Z
Hitain Goyal says
I’m getting the same error!!! Could you please help me in resolving this error!!!
Thanks
Giggione says
you have to send a POST request not a GET
robson says
{“error”:true,”message”:”You are not authorized”}
Z says
I was able to resolve my error after going over the tutorial above. I missed the part about POSTMAN where it said to click on the “body” section and use it instead of the headers. After doing that the error went away, hopefully this will help someone else.
Amirhossein Aghajani says
thanks!
how to show table from database in swift ?
mika says
hello,
I have an issue with JSONSerialization :
Error Domain=NSCocoaErrorDomain Code=3840 “No value.” UserInfo={NSDebugDescription=No value.}
I don’t understand what it means. Could you help me please ? Thank you very much for this amazing tutorial !
nomac says
Just xtra info — for the Newbies in Xcode: Connect the UI to Source Code see: https://developer.apple.com/library/content/referencelibrary/GettingStarted/DevelopiOSAppsSwift/ConnectTheUIToCode.html
I have been struggling with the execution of the Swiftcode…
This is a Cool Tutorial!!!
Diego says
This is the code fully functional on Swift 4:
import UIKit
class ViewController: UIViewController {
let URL_SAVE_TEAM = “http://192.168.1.64/MyWebService/api/createteam.php”
@IBOutlet weak var textFieldName: UITextField!
@IBOutlet weak var textFieldMember: UITextField!
@IBAction func Login(_ sender: UIButton) {
//created NSURL
let requestURL = URL(string: URL_SAVE_TEAM)
//creating NSMutableURLRequest
let request = NSMutableURLRequest(url: requestURL!)
//setting the method to post
request.httpMethod = “POST”
//getting values from text fields
let teamName = textFieldName.text
let memberCount = textFieldMember.text
//creating the post parameter by concatenating the keys and values from text field
let postParameters = “name=”+teamName!+”&member=”+memberCount!;
//adding the parameters to request body
request.httpBody = postParameters.data(using: String.Encoding.utf8)
//creating a task to send the post request
let task = URLSession.shared.dataTask(with: request as URLRequest) {
data, response, error in
if error != nil {
print(“error is \(String(describing: error))”)
return
}
do { //parsing the response
let myJSON = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary //converting resonse to NSDictionary
//parsing the json
if let parseJSON = myJSON {
//creating a string
var msg : String!
//getting the json response
msg = parseJSON[“message”] as! String?
//printing the response
print(msg)
}
} catch {
print(error)
}
}
//executing the task
task.resume()
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
masataka says
Thanks! I finally succeeded!
Chef Dennis Barimah says
Hi Belal, please I have been able to insert into my MYSQL database and even fetch from the table, but my issue is I have a live server which I have hosted my apis the url works well when I use postman to test but I can’t use my iPhone 7 simulator to fetch from the live server. I always get connection lost in my log. Please any advice. Thanks
mike says
thanks but i have to use $_GET instead of $_POST to make it works, do you have an idea why ?