mh9
mh9

Reputation: 45

php web code connect to firebase database

hi if i had a php code with mysql database the function of code is to insert data to database :-

<?php
 define('HOST','localhost');
 define('USERNAME', 'root');
 define('PASSWORD','');
 define('DB','insert2');

 $con = mysqli_connect(HOST,USERNAME,PASSWORD,DB);

 $username = $_POST['username'];
 $password = $_POST['password'];

 $sql = "insert into users (username, password) values ('$username','$password')";

 if(mysqli_query($con, $sql)){
 echo 'success';
 }
?>

now if i want to connect it with firebase database instead if mysql database i searched a lot but i can't understand how i know how to connect android app to firebase database but i don't how to connect web with firebase database

anyone help me please what should i add to the code above ?

Upvotes: 1

Views: 1579

Answers (1)

Difster
Difster

Reputation: 3270

You should be using PDO. Here's an example of the connection string. You will need to go through some tutorials on PDO usage in general though.

<?php $str_conn="firebird:host=localhost;dbname=/var/lib/firebird/2.5/data/employee.fdb;charset=UTF8";
$dbh = new PDO($str_conn, "sysdba", "masterkey");
?>

Upvotes: 1

Related Questions