Android Java + IOS Swift + php API – Login & Registration with php MySQL

Advertisement CoverGirl APP
To be a Pop CoverGirl
Find Your Hot Party or Event!

Android Java + IOS Swift + API – Login & Registration with php MySQL


Nearly Every APP or Mobile game also need the login and registration functions. You would concentrate on your core function and don’t want to spend time to deal with the login and registration. This Post will talk about how to make the basic login and registration and the simple Backup using php and MySQL. Registration and login are parts of almost all of the APP also need.


First Part: Login and Registration API with PHP MySQL

In this android and IOS login and registration post Most common login and registration will contain 3 parts. The User Registration Screen, User Login Screen and the User Profile Screen.

The server side part will be using PHP and MySQL with our XAMPP (you can use wamp or lamp as well) server. PHP and MySQL are most common tech for building the web application. You may use phpMyAdmin to create your database and Query SQL command.

Firstly, we create the database to store our user information.

Creating Database

We need to store some basic information like username, password email and Registration Date.


Now we have our database table where we will store the user data. Now lets create a PHP Project for our Web Services.

Connecting to the Database

So inside your project folder create a new php file named dbConnect.php. We will use this file to connect to the database. So write the following code inside.

Creating Web Services API using php

The first part creating web services for User Signup. we will be using one API for handle both login and registration, so we will use the GET to separate 2 parts of our php API First part is the Registration. we need to use $_POST to get the data from our app whether it from ios or android. After get the $_POST of user name, password and Email. We need to check the Username and E-mail are already registered? If the user is not registered, we can INSERT those POST data to the database.

The second Part of the API would be Login. We can use SELECT to retrieve the data and check the password is correct or not.

So we are finished creating with php API. Now lets go to android Studio. Android Studio is the most update tool to write code for android and testing your APP You can download Android Studio from their main site:


Second Part: Installation of Android Studio


Android Login, Registration and User Preference

Now here comes the android part. The first thing we will do on the android side is the register operation. So lets create a new Android Studio Project.

Creating a New Android Project

Now create an android project with Empty Activity. I created a project named

Once the project is completely loaded we will create two more activities in our project. As we will have 3 screens so first create all the 3 screens. The first screen is created by default we need to create the other two. For this right click on your package go to new -> activity -> EmptyActivity. Do this two times and create LoginActivity and ProfileActivity.
So finally we have MainActivity for registration, LoginActivity for login and ProfileActivity for the user profile that we will show after login.

Designing User Interface

First we will start designing all the screens. We have 3 Activities so lets start with designing the registration screen which is activity_main.xml (res->layout->activity_main.xml).

Registration Screen

For registration screen (activity_main.xml) we will design the screen as shown below.

Profile Screen

Now lastly I have following for the profile screen.

Remember in the above code you need to change the IP according to your system.

Class for Sending http Request

As we need to send POST Request to our Web Service URL. So to make it simple lets create a separate class that will handle the Request.
So I am here creating a class named

Now thats all for the helper classes. Lets code the app functionalities now.

Adding Internet Permission in the Manifest

As we are going to perform network operation. We have to add internet permission in the AndroidManifest.xml file.

So it is working fine. But we need to code the Profile Activity now.

Completing Profile Part

Now come inside and write the following code.

Completing Login Part

Come inside and write the following code.

Android Login and Registration Source Code Download

All source code contains the Android Studio Project, IOS xcode, PHP Files and Database File can be download from here:



Third Part: iOS Development – Getting Started with xcode and Swift 4

The above part is Android Application Development now it come to start the iOS Development using Swift 4. So if you want to learn iOS Development with


iOS Development

If you are going to start with this iOS Development you should have the following pre requisites.


• MacBook (Or you can run OS X in virtual machine as well)
Installing xcode in your MAC
First you need to install xcode in your MAC. xcode is an official IDE by Apple. And with xcode we can develop application for Apple Devices.
In this iOS Development Tutorial we will be learning app development for iPhones.
So to get started with iPhone Application Development we need a xcode. Though there are other tools as well to develop apps, but we will be using xcode as it is the official tool by apple.
Installation is very easy just follow these steps to get xcode or you can skip this step if you have it already.
• Go to App Store.
• You will see search on the right top corner, just write xcode and hit enter.

The first option you can see in the above screenshot is what we need.
And click on Install.

Download Older Version of xcode


Getting Started with xcode

We got the tool to develop apps for iOS. Now lets see how we can start our project in xcode.

Go to finder and open xcode.

WE can start the template of Single View Application. As this is just the beginning So select Single View Application and click on next.


Now you will see the below screen. Here we need to fill some information related to the iOS App that we are going to create.

Product Name: The name of your app it can be anything.
Organization Name: Put your organization name, I have given my own name here.
Organization Identifier: We often put a domain name here so I have given my websites domain.
Language: The language you want to develop your app in. In this iOS Development Tutorial we will be using Swift so I have selected Swift.

You also can select which version of swift in this page

Devices: The device for which you are creating the application and this iOS Development Tutorial is for iPhones so I have selected iPhone.

Now again hit Next and you will be asked to select a location for the project. You can choose any location and save your project.

Overview of xcode Interface

So our first xcode project for iOS Application Development is ready. Before moving ahead lets understand the xcode interface.

You can see the screen has basically 3 parts. The first on the left is the project directories. In the middle you can see the application details. And in the right some more details are there.


Testing the App in Simulator

We haven’t done anything but still we have a Single View App . So how you will test your app. xcode gives us Simulators where we can launch our app to test.

Click on the Play Button on the top.

We have our first iPhone App  But wait it is only a white screen.

We will learn about designing and coding now.

Swift + PHP + MySQL – Connecting iOS App to MySQL Database

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 10

In the First part we have already setup the MySQL database and the API

Now we Create the Registration page

Swift PHP MySQL Tutorial

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.

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.

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

After finish the Registration page. We need to build the Login page now.

We can have the button to go to login page if user have already registered.

Finally we do the User Preference Page for display the user information and Logout Button.

Finally: php Admin Backend page

We also create some php pages as a backend so that we can see the user registration info.

All source code contains the Android Studio Project, IOS xcode, PHP Files and Database File can be download from here: CoverGirl APP
To be a Pop CoverGirl
Find Your Hot Party or Event!
tutorial.catcatgamer CoverGirl APP
To be a Pop CoverGirl
Find Your Hot Party or Event!