MySQL Registration Help

I want to use this code on my app but I don’t know how to run this in Kodular but in the android studio it’s work perfect

I tried many ways but whenever i try to run this code it shows this message

{“error”:true,“error_msg”:“Required parameters (name, email or password) is missing!”}

I Don’t know how to send these values in kodular

Register.php code

<?php

require_once ‘DB_Functions.php’;
$db = new DB_Functions();

// json response array
$response = array(“error” => FALSE);

if (isset($_POST[‘name’]) && isset($_POST[‘email’]) && isset($_POST[‘password’])) {

// receiving the post params
$name = $_POST['name'];
$email = $_POST['email'];
$password = $_POST['password'];

// check if user is already existed with the same email
if ($db->isUserExisted($email)) {
    // user already existed
    $response["error"] = TRUE;
    $response["error_msg"] = "User already existed with " . $email;
    echo json_encode($response);
} else {
    // create a new user
    $user = $db->storeUser($name, $email, $password);
    if ($user) {
        // user stored successfully
        $response["error"] = FALSE;
        $response["uid"] = $user["unique_id"];
        $response["user"]["name"] = $user["name"];
        $response["user"]["email"] = $user["email"];
        $response["user"]["created_at"] = $user["created_at"];
        $response["user"]["updated_at"] = $user["updated_at"];
        echo json_encode($response);
    } else {
        // user failed to store
        $response["error"] = TRUE;
        $response["error_msg"] = "Unknown error occurred in registration!";
        echo json_encode($response);
    }
}

} else {
$response[“error”] = TRUE;
$response[“error_msg”] = “Required parameters (name, email or password) is missing!”;
echo json_encode($response);
}
?>

1 Like

This script will be on your server. The web component will receive a url where this scrpt is. You will do post or Get to use the script, passing parameters or taking the result of the script.

I Know it’s a server side script But in kodular i don’t know how to pass parameters

can you help me ?

1 Like

Web component, POST Text method. Text is the parameter (if you need to pass some for the script to work and return something) This parameter can be the text property of a Text box where the user typed the email.

https://puravidaapps.com/mysql.php

I Test this but it didn’t work

1 Like

Try this way

Please define what doesn’t work…

I’m also using this on my app but i want to create a Login-Registration in MySQL

1 Like

When i click on the button it shows this message

{“error”:true,“error_msg”:“Required parameters (name, email or password) is missing!”}

1 Like

Looks like your if else are not structured properly, in the end i saw only else doesn’t know where is if condition for that.

In order to debug the issue first see from which part of code error is displayed then go back from there on what condition your code will reach there.

Note that here, check for 3 parameters. They are not arriving via POST.

Sorry, I didn’t understand why you used it that way.

Thanks for your help guys
@Rogerio_Rios
@Meghraj_Singh

There was a problem with my code and I Fixed It.

1 Like

Code PHP ? Or blocks Kodular that were not shown to us?

Both PHP Code, Kodular Block

1 Like

That’s why it’s important to always show us the most relevant blocks. :+1:

1 Like

I Posted all the blocks that i have used in my App

1 Like

Well, in php, it was going to the else, which happened because one of the parameters in POST had not been passed. In the kodular, I did not understand very well that block that I made the drawing in the post above.

Semicolons…

1 Like

I Created a Guide Post in Detail
Now it’s pending for approval

1 Like