React Native User Registration using PHP MySQL Database PART-2- Writing App Code

This tutorial is the 2nd part of our previous tutorial Creating PHP Api for User registration. In previous tutorial i have explained about how we can create PHP Api which received data from our react native application and insert data into database. In this tutorial we would learn about writing code for app so we would get data from app user and send that data to our online hosting server and after done successfully we would print the response on app screen using Alert dialog box.

Content in this project React Native User Registration using PHP MySQL Database PART-2- Writing App Code:

1. The first step is to read our previous tutorial about Creating PHP API and make your own API using my code.

2. Open your project’s App.js file and import StyleSheet, TextInput, View, Alert, TouchableOpacity and Text component.

3. Create your main export default class named as App.

4. Creating constructor() in your App class. In the constructor we would make 3 States named as name, email and password. These states will hold the values of all 3 Text Input components.

5. Creating a function named as registration_Function() in your App class. In this function we would first pass our Server domain URL with our created PHP API file like i did in below code. Now using the JSON.stringify method we would convert all 3 states data into JSON format and send to the URL. After sending the data the response come from server and we would print that response string in alert. We would call this function on click event.

6. Creating 3 Text Input and 1 Touchable opacity component in render’s return block to make our main view. In TextInput we would simply updating the state value on change text event.

7. Creating Style.

8. source code for App.js file class.


React Native User Registration using PHP MySQL Database PART-2- Writing App Code


  1. im sorry sir, im not good for english.
    why my react native when fetch post return “network request failed”
    I use android.
    Thank you sir

    • Bro did you testing my code or updating the code as requirement ?

    • Hey!! No problem dude. Just change the json method to text method when fetching the response from the server. Because the response you are getting from it is in the string form.

  2. I have done everything you did yet i am not getting any response.
    What am i doing wrong.

  3. Thank you for the lesson!
    I have two questions:
    1. My application is in Russian and when entering data in Russian into the database incorrect characters are saved. How to change the encoding?
    2. How in case of successful registration to get to the following form, and in case of failure to stay on this?

    • Anton i have not tested any application yet in Russian language but i will check the app in Russian language .

  4. Have any results? I have the same problem here:

    When I get data from DB the result is – ‘????? ???’

  5. i got a response : JSON parse error: unexpected EOF. what does it means?

    • Arrief If you are using my API WEB URL then you will see the error because my API URL is deleted from the server. So you have to make you own using my code.

Leave a Reply

Your email address will not be published.