Как подключить БД phpMyAdmin к приложению?

У меня есть приложение в котором есть авторизация пользователя, я подключаю файл login.php, в кортом идёт подключение к БД phpMyAdmin, я хочу чтобы когда пользователь авторизовался и зашёл в свой профиль то он мог видеть всю инфу которую вносил в БД, то если человек зарегистрировался и при регистрации ввёл тел., маил, фамилию, имя, отчество, а когда залогинился, в профиле увидел всю инфу о себе. К примеру есть TextView, как из БД вытянуть в это TextView какую-то инфу фамилию или тел.? Есть какой-то пример как это реализовать? Нужно отдельно подключать БД на прямую а не через login.php или как?

Вот xml файл там есть 2 TextView. 1й это имя, 2й это фамилия как сделать чтобы из БД там отображались данные?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <ImageView
            android:layout_width="144dp"
            android:layout_height="144dp"
            android:src="@drawable/ic_baseline_account_circle_24" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:id="@+id/Name"
                android:layout_width="match_parent"
                android:layout_height="72dp"
                android:gravity="center"
                android:textSize="20sp"
                android:textColor="@color/color_2"/>

            <TextView
                android:id="@+id/Surname"
                android:layout_width="match_parent"
                android:layout_height="72dp"
                android:gravity="center"
                android:textSize="20sp"
                android:textColor="@color/color_2"/>
        </LinearLayout>
    </LinearLayout>

    <androidx.cardview.widget.CardView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="6dp"
        android:backgroundTint="@color/color_2"
        app:cardCornerRadius="6dp"
        app:cardElevation="0dp">

        <androidx.cardview.widget.CardView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="1dp"
            app:cardCornerRadius="5dp"
            app:cardElevation="0dp">

            <Button
                android:id="@+id/logout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/color_6"
                android:paddingHorizontal="6dp"
                android:text="Выйти из аккаунта"
                android:textAllCaps="false"
                android:textColor="@color/color_2"
                android:textSize="24sp"
                android:textStyle="normal" />

        </androidx.cardview.widget.CardView>
    </androidx.cardview.widget.CardView>
</LinearLayout>

login.php

<?php

$Email = $_POST["Email"];
$Password = $_POST["Password"];

require "init.php";

if($con)
{
    $sql = "select name from login_info where Email='$Email'and password ='$Email'";
    $result = mysqli_query($con,$sql);
    if(mysqli_num_rows($result)>0)
    {
        $row = mysqli_fetch_assoc($result);
        $status = "ok";
        $result_code = 1;
        $name = $row['name'];
        echo json_encode(array('status'=>$status,'result_code'=>$result_code,'name'=>$name));
    }
    else
    {
        $status = "ok";
        $result_code = 0;
        echo json_encode(array('status'=>$status,'result_code'=>$result_code));
    }
}
else
{
    $status = 'failed';
    echo json_encode(array('status'=>$status),JSON_FORCE_OBJECT);
}
mysqli_close($con);
?>

init.php

<?php

$username = "a347943";
$password = "";
$dbname = "a347943_test_db";
$hostname = "a347943.mysql.mchost.ru";
$con = mysqli_connect($hostname,$username,$password,$dbname);

mysqli_set_charset($con,"utf8");
?>

Ответы (0 шт):