Ottoman
(Muhammad Usman)
June 9, 2020, 3:40pm
#1
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.
Ottoman
(Muhammad Usman)
June 9, 2020, 3:49pm
#3
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.
Ottoman
(Muhammad Usman)
June 9, 2020, 4:04pm
#6
I Test this but it didn’t work
1 Like
Please define what doesn’t work…
Ottoman
(Muhammad Usman)
June 9, 2020, 4:07pm
#9
I’m also using this on my app but i want to create a Login-Registration in MySQL
1 Like
Ottoman
(Muhammad Usman)
June 9, 2020, 4:08pm
#10
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.
Rogerio_Rios
(Professional Support)
June 9, 2020, 5:59pm
#12
Note that here, check for 3 parameters. They are not arriving via POST.
Rogerio_Rios
(Professional Support)
June 9, 2020, 6:04pm
#13
Sorry, I didn’t understand why you used it that way.
Ottoman
(Muhammad Usman)
June 9, 2020, 11:11pm
#14
Thanks for your help guys
@Rogerio_Rios
@Meghraj_Singh
There was a problem with my code and I Fixed It.
1 Like
Rogerio_Rios
(Professional Support)
June 9, 2020, 11:13pm
#15
Code PHP ? Or blocks Kodular that were not shown to us?
Ottoman
(Muhammad Usman)
June 9, 2020, 11:13pm
#16
Both PHP Code, Kodular Block
1 Like
Rogerio_Rios
(Professional Support)
June 9, 2020, 11:14pm
#17
That’s why it’s important to always show us the most relevant blocks.
1 Like
Ottoman
(Muhammad Usman)
June 9, 2020, 11:15pm
#18
I Posted all the blocks that i have used in my App
1 Like
Rogerio_Rios
(Professional Support)
June 9, 2020, 11:18pm
#19
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
Ottoman
(Muhammad Usman)
June 9, 2020, 11:38pm
#20
I Created a Guide Post in Detail
Now it’s pending for approval
1 Like