я хочу подключить базу данных Postgresql к Android App React - родной - PullRequest
0 голосов
/ 31 мая 2019

Каждый, кто пользуется веб-сайтом odoo12 с базой данных postgresql, и я создаю приложение с использованиемact-native, и я хочу связать свое приложение с базой данных postgresql по тому, как база данных разделяется на другом сервере, где я работаюВы помогаете мне, пожалуйста?Я жду вашего ответа

с наилучшими пожеланиями eyounes

Everyone
i'm Using odoo12 site web with database postgresql
and I Create an app Using react-native , and i want to connect my app with 
postgresql database
by The way The Database is separated in another server wher i'm working
Could you help me Please ?
I'm Waiting For your Response

best regards
eyounes

/*************** Login Code ************/
UserLoginFunction = () =>{

const { username }  = this.state ;
const { password }  = this.state ;
fetch('http://192.168.43.56/ff/users.php', {
      method: 'POST',
      headers: {
         'Accept': 'application/json',
         'Content-Type': 'application/json',
       },
       body: JSON.stringify({

        username: username,

         password: password

       })

     }).then((response) => response.text())
           .then((responseJson) => {

             // If server response message same as Data Matched
            if(responseJson === 'Data Matched')
             {enter code here

                 //Then open Profile activity and send user email to profile activity.
                 this.props.navigation.navigate('intervention', { Email: UserEmail });

             }
             else{

               Alert.alert(responseJson);
             }

           }).catch((error) => {
             console.error(error);
           });

       } 

    /********************** DbConfig.php *********************/

 <?php

  //Define your host here.
  $HostName = "Odoo-serv12";

  //Define your database name here.
  $DatabaseName = "Lpn_auto";

  //Define your database username here.
  $HostUser = "openpg";

  //Define your database password here.
  $HostPass = "openpg";

  ?>
/******************* users.php *****************/
<?php

 // Importing DBConfig.php file.
 include 'DBConfig.php';

 // Creating connection.
  $con = pg_connect($HostName,$HostUser,$HostPass,$DatabaseName);

  // Getting the received JSON into $json variable.
  $json = file_get_contents('php://input');

  // decoding the received JSON and store into $obj variable.
  $obj = json_decode($json,true);

 // Populate User email from JSON $obj array and store into $email.
 $username = $obj['login'];

 // Populate Password from JSON $obj array and store into $password.
 $password = $obj['password'];

 //Applying User Login query with email and password match.
 $Sql_Query = "select * from res_users where login = '$username' and password = '$password' ";

 // Executing SQL Query.
 $check = pg_fetch_array(pg_query($con,$Sql_Query));


 if(isset($check)){

  $SuccessLoginMsg = 'Data Matched';

  // Converting the message into JSON format.
 $SuccessLoginJson = json_encode($SuccessLoginMsg);

 // Echo the message.
  echo $SuccessLoginJson ; 

  }

  else{

  // If the record inserted successfully then show the message.
 $InvalidMSG = 'Invalid Username or Password Please Try Again' ;

 // Converting the message into JSON format.
 $InvalidMSGJSon = json_encode($InvalidMSG);

 // Echo the message.
  echo $InvalidMSGJSon ;

  }

pg_close($con);
 ?>

Вот все, что сходит с ума О Спасибо

Это ОШИБКА у меня

...