React Native User Registration with Local PhpMyAdmin MySQL Database iOS Android Tutorial

Our this tutorial has a special purpose between developers, because many of our visitors wanted to test react native apps using Local PhpMyAdmin MySQL database and most of them doesn’t know how to? So in this tutorial we would going to create simple User Registration with Local PhpMyAdmin MySQL Database application in both iOS Android devices example tutorial. We would explain each and every step in this tutorial so don’t skip any step read the tutorial to end. Happy Reading 🙂 .

Contents in this project User Registration with Local PhpMyAdmin MySQL Database iOS Android Example Tutorial:

1. The first step is to install the Local PHP server software in your computer, We are using the XAMPP in our tutorial, So if you have n’t install the XAMPP then download from its official website , It’s free.

2. After installing the XAMPP just start the Apache and MySQL server.

3. Create MySQL database and Table:

  1. Next step is to create MySQL database in your local host PhpMyAdmin, So open your web browser(Google chrome, Mozilla Firefox etc.) and type  localhost/phpmyadmin and press enter, Now you’ll see the Localhost/PhpMyAdmin MySQL database control panel.
  2. Click on New link to create new MySQL database.
  3. Enter the Database name, we are creating the Database named as test.
  4. Next step is creating Table in your Local database, Enter table name as user_details with columns 4.
  5. Enter columns name id, name, email, password with type INT and VARCHAR. Now make the id as auto increment and make the id is primary key. 
  6. Now the table creating part is done, Next step is start coding for PHP server files.

4. Creating PHP Files:

we have to create 2 php files first one is dbconfig.php and second is user_registration.php .

Code for dbconfig.php file:

This file contains all the most useful information about our server like server database username, host name, password and database name.

Code for user_registration.php file:

This file is used to insert user registration information data into MySQL database table. We would call this file into our react native code.

5. Create a folder name as User_Project inside C:\xampp\htdocs\ like i did in below screenshot and copy the both dbconfig.php and second is user_registration.php PHP files inside this folder. We would now call these files with IP of our local system.

6. Open command prompt in windows and execute ipconfig command inside it to see your system’s IP address.

Important Note : After executing above command you’ll see many different IP address on your command prompt window, Now if you are connected to WiFi network then you need to copy/select the IPv4 address under Wireless LAN Adapter WiFi block and if you are connected to LAN then select the IPv4 address under Ethernet Adapter.

7. Start Coding for Application :

1. Open your project’s App.js file and import StyleSheet, View, TextInput, Button, Text and Alert component in your project.

2. Create constructor() in your project and make 3 state named as UserName, UserEmail and UserPassword inside it.

3. Create a function named as UserRegistrationFunction(), Inside this function we would use the fetch() API to insert data into MySQL database, As you can see we are using the URL with IP address mentioned above step with the location of PHP file. After inserting the data successfully it will print the response message coming form PHP file in Alert.

4. Create 3 TextInput component and 1 Button component inside the render’s return block, Each TextInput will get a value from user and stores in State. We would call the UserRegistrationFunction() on button onPress event.

5. Creating Style.

6. Complete source code for App.js File :

Screenshots :

User Registration with Local PhpMyAdmin MySQL


  1. awesome, thank you very much

  2. sir my all configuration is right but still getting network request error.

    please help.

    • Abhishek could you test your code on online hosting server like 000webhost.

    • can you verify the host name in DB connection php file . I did the same mistake, In dbconfig.php I give localhost and In App.js I given network IP. If not same change it. And Postman is very helpful you can verify your connection

  3. Thank you sir
    greate tutorial

  4. i have following error, please help me
    JSON Parse error: Unexpected Identifier “Try”

  5. sir im having this error pls can you help JSON Parse error: Unrecognized token ‘<'

  6. JSON Parse error: Unrecognized token ‘<'. This is my error

  7. hi,
    my code works great on local but when i put code on 000webhost then i receive getting network request error … help me ?

    • Ali you need to change the your server database name and sever database password in config file and make sure when you are trying this your emulator or mobile is connected to internet .

    • Actually free hosting for 000webhost is not accepting external http request. All the request is blocked by their server. Try using firebase as a database.

  8. JSON Parse error: Unrecognized token ‘<'.
    and where is database config file

  9. Hi,
    I want to create a registration and login app and whenever i fill registration form then all information should goes in local database and will able to login with these credentials. Please help me how can i will create this. I am stuck in this from last 10 days. My main focus local database and this database access in mobile without using internet or firebase.

  10. Hi, when i make the register it takes too much time to success on android, on ios it work really fast. I put alerts everywhere to see what was the problem and i can see that when it time of “fetch” it is when the delay happend, about 10 seconds.
    do you know whats going on ?
    any solution?
    please help me


  11. i try to run it using wampserver but dont get , it has occur an error ( JSON Parse error: Unrecognized token ‘<')

  12. I have same problem with (JSON Parse error: Unrecognized token ‘<')

    but i make sure i have set the right database username password and database name …

  13. I have same problem with( JSON Parse error: Unrecognized token ‘<')

    I make sure i have set the right information in the config file

  14. while i run this code i receive this following error.
    JSON Parse error: Unrecognized token ‘<'

  15. I was able to solve the “JSON Parse error: Unrecognized token ‘<'" error…make sure you check the state name is the same E.g
    name: this.state.UserName,
    email: this.state.UserEmail,
    password: this.state.UserPassword.
    Moreover, the name , email , password must be the same as in the php page

  16. Will can use the same fetch method for react as well rite?

  17. Can you wake a tutorial of user log in using php myadmin ?

  18. Can you make a tutorial of user registration process using PostgreSQL

    • Thanks for your suggestion Adnan but sadly i have not tried the PostgreSQL yet. But when i learn about PostgreSQL then surely i’ll post tutorial on it.

  19. I am trying but yet not succeeded, its hard but its not impossible.

  20. Yesterday i did user registration process using PostgreSQL and succeeded……

  21. Hey sir, code is run but give this alert — … — What is it ?

  22. Hi, if I want to show the id in the alert box after I successfully register, what should i do in the PHP and react code? Thanks

  23. and how to pass the id from php code after insert? Should i add another query to select the id?

  24. Could you explain more how to pass it? I try $MSG = array (‘User Registered Successfully’, $id) and in react native is Alert.alert(responseJSON[1]), but it get error like this: [SyntaxError: JSON Parse error: Unrecognized token ‘<']

    • Farah did you application running correctly before making these changes ?

      • Hi, I am trying this currently and the application gives this same error even without making changes to the code. I also sent you an email. Could you help please?

  25. Can we user the same method for react js as well,

    If not is there any similar link

  26. i am using react and using the same code to try to connect with mysql, will it work

  27. Thanks for the reply!!
    I am getting this error – any suggestions “If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.”

  28. Yes, my application is running well before i change the code to send the ID

  29. Hello! thank you for showing us this, its so useful! however it is possible to link the pop up message of ‘ User Registered Successfully’ OK button to a new page ?

    Waiting for your reply!

    Thank you!

  30. Hi, i am getting SyntaxError: JSON Parse error: Unrecognized token
    I have check the dbconfig file and everything else.
    It also works when I directly specify the $name, $password, and $email fields in the userRegistration file.
    So it seems like it is not able to get the the input from the app.

    I am using Wamp server, does this affect anything?

  31. Using your code as well url is also yours but it is not registering user. what is the problem. if i am using local host it is showing unrecognized token. i am using htdocs/web/file
    and user is

  32. how to connect the react application with these files(.php)

    • Afif you have to upload these PHP files on your server and your sever should be connected with Domain name. Now after uploading these files to server you will get a URL which is your API URL.

  33. I’m getting : Network request field but after 2 mins of submitting the info entered! and I’m using wamp server.

  34. Marcelo Cordeiro

    Hi, good tutorial, do you know if it works with genymotion? which emulator did you use?

  35. sorry for my bad english,
    thanks a lot for tutorial, great!!!

    the app 100% work.

    but if i release the apk, then install on my phone, and connect on same network, the app not working and nothing alert anything. why? any solution

    • Thanks for telling me this Ammar, I will install it in my phone and test it ASAP .

      • thanks for reply,
        but the function is working 100% for now, i dont know why.

        FYI on your posting about get data from API, the ListView not working, i try with FlatList and working.

        Finally, i release the apk, and install on phone, both insert and get data 100% work, AWESOME 😉

  36. Hi
    I’m getting this error: JSON Parse error: Unexpected Identifier “Try” It happened when I signed up for the second time. While the registration process was successful for the first time and the data was sent to the database. Can you tell me where is the error?

  37. Thank you So much 🎉 ! Great tutorial .. Each step is very clear And easy to grasp it for beginners

Leave a Reply

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