Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp

Store data to mysql server from MIT App Inventor using php

Store data to mysql server from MIT App Inventor using php, sound some thing interesting. As we know, it is very important topic. Because after getting the knowledge, the process of store data to mysql server from MIT App Inventor using php, we can implement it in various project like register and login system, storing record and lots more.

Now question is how can we Store data to mysql server from MIT App Inventor using php?

For that, I made a simple project making a Android app of registration form using MIT App Inventor. So for completing the project we need to do with some simple steps. those are discuss below.

    First step we have to build mysql database for specific field in registration form.

    Second step we have to write php code to collect the data form app and store it to mysql database.

    Third step we have to design a registration form on MIT App Inventor.

     Fourth step we have to give proper logical block connection for registration form on MIT App Inventor.

      Fifth step we have to Hosted domain.

 Building mysql database: 

It is very easy to building a mysql database in any hosted domain. For that go to their control panel and enter into phpMyAdmin. After entering inside phpMyAdmin, we can able to see the name of database at left hand side menu bar. Which is shown in bellow image.

Store data to mysql server from MIT App Inventor using php

Now some importing thing we have to do. We need a table to store data to MySQL server from MIT App Inventor using php. As well as we need same field as in registration form as the table we made. We have to show concentration to do that. If is any mismatch found in form and MySQL database then it give error. so very careful to doing that. Hence main concern is how can we create the MySQL table? To create a new table in database we have to give a table name and number of field required and we have to press go button. Congratulation Now we successfully created the table.

After creating database now we have to enter the details of field like field name, length, type, attribute etc.

how can we create the MySQL table?

Now a days you can find lots of free web hosting service provider with free subdomain to work with your project. I used 000webhost for making my project. You can also use that. I also made a simple video with this complete process. You can see the bellow video to get full process of making a mysql database.

 PHP code to collect the data form app: 

In above section we learn making a mysql database in web server. Now to complete the project we have to store data to mysql server from MIT App Inventor using php. What can we do for that? It is very simple. Our next step will be writing PHP code to collect the data form app. In bellow I give complete PHP code for table nbcafe with above fields shown in above picture.

<?php
define (‘dbuser’,’your db user’);
define (‘dbpw’,’your db password’);
define (‘dbhost’,’your db host’);
define (‘dbname’,’your db name’);
$dbc = mysqli_connect(“your db host”, “your db user”, “your db password”, “your db name”);
if(!$dbc) {
die(“DATABASE CONNECTION FAILED:” .mysqli_error($dbc));
exit();
}
$dbs = mysqli_select_db($dbc, dbname);
if(!$dbs) {
die(“DATABASE SELECTION FAILED:” .mysqli_error($dbc));
exit();
}
$firstname = mysqli_real_escape_string($dbc, $_GET[‘firstname’]);
$lastname = mysqli_real_escape_string($dbc, $_GET[‘lastname’]);
$fathername = mysqli_real_escape_string($dbc, $_GET[‘fathername’]);
$mobile = mysqli_real_escape_string($dbc, $_GET[‘mobile’]);
$dob = mysqli_real_escape_string($dbc, $_GET[‘dob’]);
$class = mysqli_real_escape_string($dbc, $_GET[‘class’]);
$school = mysqli_real_escape_string($dbc, $_GET[‘school’]);
$email = mysqli_real_escape_string($dbc, $_GET[’email’]);
$address = mysqli_real_escape_string($dbc, $_GET[‘address’]);
$user_id = mysqli_real_escape_string($dbc, $_GET[‘user_id’]);
$psw = mysqli_real_escape_string($dbc, $_GET[‘psw’]);
$query = “INSERT INTO nbcafe (first_name, mobile_number, date_of_birth, class, school_name, email, user_id, psw) VALUES (‘$firstname’, ‘$mobile’, ‘$dob’, ‘$class’, ‘$school’, ‘$email’, ‘$user_id’, ‘$psw’)”;
if(mysqli_query($dbc, $query)){
echo “Records added successfully.”;
} else{
echo “ERROR: Could not able to execute $query. ” . mysqli_error($dbc);
}
mysqli_close($dbc);
?>

 Design a registration form on MIT App Inventor 

Lets start with design a registration form on MIT APP Inventor. For that I used eight label to write our eight filed name. Seven text field box to take text input. One password text box to take password. And one button to make register button. For working with programming logic, we have to take Non-Visible component like Web1 and Notifier1.

Design a registration form on MIT App Inventor

 Logical block connection for registration form : 

If you are working with MIT App Inventor. Then you know, it need programming with logic blocks. For beginner do not take tension you can see me post How to make your own android apps without programming?  The main portion of this project is proper logical block connection for registration form. The main aim of this app is take the input data and send it to PHP by making exact url.

  1. So first work of our app will be making url with user data.

Store data to mysql server from MIT App Inventor using php

  1. After sending proper url to PHP, Second work has to get the server response. In above mention PHP I wrote, if data added successfully it show massage “Records added successfully.” If any problem arrived it show massage “ERROR: Could not able to execute”. So for that we have to definitely add some logic box.

Store data to mysql server from MIT App Inventor using php

So in this way we can easily Store data to MySQL server from MIT App Inventor using PHP.

For beginner i made the video on that. I can watch that it well explain. The complete video with step by step process shown below.

 Conclusion 

Store data to mysql server from MIT App Inventor using php

Hope this post give you enough knowledge to make and Store data to mysql server from MIT App Inventor using php.

Not Enough, Need More

E-Mail Subscription





E-Mail Subscription





Table of Contents
Subham Dutta

Subham Dutta

Hi myself Subham Dutta, having 15+ years experience in filed of Engineering. I love to teach and try to build foundation of students. Try to make them imagine what they learn.

Need more this type of content in your E-Mail?



NBCAFE