React Native User Registration using PHP MySQL Database PART-1 – Creating PHP API

I have posted tutorial on this topic about a year ago and few peoples are facing problems understanding the code. So today i am making the same tutorial again with more explanation, So all the new and old users can understand it easily. In this tutorial we would create react native application with user registration form containing 3 TextInput fields User Name, User Email and User Password. After submitting the values the data goes to our web server. Where we would receive the data using PHP API and using the MySQL queries we would insert the data into MySQL database. So let’s get started :).

NOTE: We are using 000webhost.com website for testing our PHP API + MySQL database. This website is amazing guys and gives us almost every facility to test our applications using free online server. They gave us free sub domain of which i am using in this tutorial. Our testing sub-domain is reactnativetestapi.000webhostapp.com/ .

Contents in this project React Native User Registration using PHP MySQL Database PART-1 Android iOS Tutorial:

1. Creating MySQL Database :

Log-In into your PhpMyAdmin control panel and create a database or you can use your own old already created MySQL database. In my case i have created the MySQL database and my database name is id10676035_react_native_test_database. You can see in below screenshot how my database looks like.

2. Creating User Registration Table in MySQL database to store user details:

1. Select your database, In which you want to create table and write your Table name in create table box with column number. I am creating a table named as user_data_table with 4 columns. I will explain all the columns name in next step. Now press the Go button to create new table.

2. In the name field you have to enter 4 columns name id, user_name, user_email and user_password. Set their Length/Values to 255 and select ID as Auto_Increment and Set ID key to Primary. For exact match see the below screenshot. You could click on the Screenshot to see it in bigger size. Now hit the Save button to create table with all details.

React Native User Registration using PHP MySQL Database PART-1 - Creating PHP API3. Here you go. Now your table is created and the Database part has completed. Next step is to create PHP API to receive data from app.

3. Creating PHP Web API to Receive data from Android iOS React Native App:

1. Now we need to make a .php extension file using Notepad or Notepad++. This PHP file would connect our MySQL database table to our react native app. Open the Notepad or Notepad++ and paste all below code and save the file with registration_api.php name. After done creating this file you have to upload this file into your Web hosting server using their File Manager our using FileZilla ftp client. Here is my domain URL after uploading this file on my own testing web server. https://reactnativetestapi.000webhostapp.com/ . After opening the domain you’ll see my file is there. We would use this file URL to test our server.

Source code for registration_api.php file:

Important Note: You have to put your own hosting server details in this file like your database HostName, Database name, Database Username, Database Password. All these details will be found on your hosting Cpanel. Get ready for NEXT part of this tutorial to learn about react native application coding.

2 Comments

  1. please make a component of multi select filters like dream11 its too needy for me plss in react native

Leave a Reply

Your email address will not be published. Required fields are marked *