Making connection Arduino to mysql using PHP part 2
Welcome back with Sahabat bisnis kalian,
have you ever heard about connecting arduino to database using php? Here we’ll learn about that.
have you ever heard about connecting arduino to database using php? Here we’ll learn about that.
This article containt of how to connect database mysql with PHP. Before that, please make the mysql databse table with xampp.
If you don’t know what is PHP, you should learn it in basic how to make php script for beginner
firstly, let’s make the database. I will give the name “learning_database”
then, write this script to your text editor ( I’am using Notepad++ )
<?php
$servername = "localhost";
$database = "learning_database";
$username = "root";
$password = "";
$konek = mysqli_connect ($servername, $username, $password, $database);
if ($konek!=false){
echo "Connection Success";
} else {
echo "Connection Failed";}
?>
save the program script in directory file : [ C/xampp/htdocs/learning_php ] with the name “connection.php”
why ? just read in basic how to make php script for beginner
then, write this link to your browser
firstly, let’s make the database. I will give the name “learning_database”
then, write this script to your text editor ( I’am using Notepad++ )
<?php
$servername = "localhost";
$database = "learning_database";
$username = "root";
$password = "";
$konek = mysqli_connect ($servername, $username, $password, $database);
if ($konek!=false){
echo "Connection Success";
} else {
echo "Connection Failed";}
?>
save the program script in directory file : [ C/xampp/htdocs/learning_php ] with the name “connection.php”
why ? just read in basic how to make php script for beginner
then, write this link to your browser
It shows that your connection is successfully
Now, let’s make the connection arduino to database.
Write this script in notepad++:
<?php
include ("connection.php");
$temp1 = $_GET['temp1'];
$hum1 = $_GET['hum1'];
mysqli_query($konek, "INSERT INTO monitoring(temp1,hum1) VALUES('$temp1','$hum1')");
?>
Save the program with the previous one (connection.php) with the name “index.php”
Now, you can run your project with the arduino and see the data in your database table. Like this one
0 Response to "Making connection Arduino to mysql using PHP part 2"
Post a Comment