Flutter + Php + Mysql

Asked

Viewed 48 times

0

Well, I’m new to flutter but basically I’m doing a simple registration with 3 fields.

Summarizing my problem is that I can register normally by Androidstudio emulator, but when Gero APK and I try to register by my mobile phone it does not perform the registration.

1 - I am using the local server Xampp, 2 - I put the fixed IP of my notebook in the url. 3 - I can access my server and view the files through the mobile browser morally(including it inserts in the table when access the data by the mobile browser).

Follow my connection code below:

_InserirDados() async {
    var url = Uri.parse("http://192.168.1.103/flutter/inserir.php");
    http.post(url,
        body: {
          "nome" : nometxt.text,
          "email" : emailtxt.text,
          "password" : passwordtxt.text
        });
        HttpOverrides.global = new MyHttpOverrides();
    
    
        
  }

My insert.php

<?php

    include("database.php");

    $nome = $_POST['nome'];
    $email = $_POST['email'];
    $password = $_POST['password'];


    $res = $pdo->prepare("INSERT INTO usuario (User_username, User_Login, User_Password) VALUES ('$nome', '$email', '$password')");
    
    $res->execute();

    if ($res) {
        echo(json_encode(array("code" => 1, "mensagem" => "Inserido com sucesso")));
    }else {
        echo(json_encode(array("code" => 2, "mensagem" => "Falha na insersão dos dados.")));    
    }



?>


  • It is the kind of problem that will hardly get help here because there is no clear error situation. Only by observing the return of your server and the treatment in the App you will be able to discover the problem.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.