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.

Screenshot:

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

2 Comments

  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

Leave a Reply

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