-1

I can't figure out how to send an email verification for user after registering on my android app. Also i don't know how to redirect to the main activity after user clicking the link of mail verification. Should i use PHP mailer? I really new in this.

I just have database that contain user table ,and an API for register on Android.I'll show the code, but this code in my language, sorry

<?php
  include_once "koneksi.php";

class user{}

$nama_depan= $_POST["nama_depan"];
$nama_belakang = $_POST["nama_belakang"];
$username = $_POST["username"];
$email = $_POST["email"];
$password = $_POST["password"];

if ((empty($nama_depan))) {
    $response = new user();
    $response->success = 0;
    $response->message = "Kolom nama depan tidak boleh kosong";
    die(json_encode($response));

}elseif((empty($nama_belakang))) {
    $response = new user();
    $response->success = 0;
    $response->message = "Kolom nama belakang tidak boleh kosong";
    die(json_encode($response));

}elseif((empty($username))) {
    $response = new user();
    $response->success = 0;
    $response->message = "Kolom username tidak boleh kosong";
    die(json_encode($response));

}elseif((empty($email))) {
    $response = new user();
    $response->success = 0;
    $response->message = "Kolom email tidak boleh kosong";
    die(json_encode($response));

} else if ((empty($password))) {
    $response = new user();
    $response->success = 0;
    $response->message = "Kolom password tidak boleh kosong";
    die(json_encode($response));
}else {
    if (!empty($username) && $password){
        $num_rows = mysqli_num_rows(mysqli_query($con, "SELECT * FROM tb_user WHERE username='".$username."'"));

        if ($num_rows == 0){
            $query = mysqli_query($con, "INSERT INTO tb_user (id_user,level_user,nama_depan,nama_belakang,username,email, password,state_verifikasi) VALUES(0,2,'".$nama_depan."','".$nama_belakang."','".$username."','".$email."','".$password."',0)");

            if ($query){
                $response = new user();
                $response->success = 1;
                $response->message = "Register berhasil, Silahkan Login";
                die(json_encode($response));

            } else {
                $response = new user();
                $response->success = 0;
                $response->message = "Username sudah ada";
                die(json_encode($response));
            }
        } else {
            $response = new user();
            $response->success = 0;
            $response->message = "Username sudah ada";
            die(json_encode($response));
        }
    }
}

mysqli_close($con);

?>

Can you tell me what should i do?

Badran
  • 515
  • 1
  • 7
  • 21
dini
  • 1
  • 5

1 Answers1

0

You can use any mailer client from server side to send email to user , answer to second question lies on concept of deep links, below thread can be helpful for you on this Make a link in the Android browser start up my app?

Ashok Kumar
  • 1,226
  • 1
  • 10
  • 14