我只是一个初学者所以帮助我!我想在本机 TextInput 中获得 JSON 响应。[我在本机应用程序中有 2 页。在第一页 ==> 我想要该 JSON 数据并导航到带有该 JSON 响应的第二页。我使用 PHP 作为服务器端脚本语言。我的PHP代码是:<?php// Importing DBConfig.php file.include 'DBConfig.php';// Creating connection. $con = mysqli_connect($HostName,$HostUser,$HostPass,$DatabaseName); // Getting the received JSON into $json variable. $json = file_get_contents('php://input'); // decoding the received JSON and store into $obj variable. $obj = json_decode($json,true);// Populate column from JSON $obj array and store into $coulmn.$firstname = $obj['firstname'];$lastname = $obj['lastname'];//$mobileno = $obj['mobileno'];$email = $obj['email'];$profession = $obj['profession'];$mobileno = '7874853188';//Applying User Login query with mobile number match.$Sql_Query = "select firstname,lastname,email,profession from member where mobileno = '$mobileno' ";// Executing SQL Query.$check = mysqli_fetch_array(mysqli_query($con,$Sql_Query));if(isset($check)){ $SuccessLoginMsg = 'Data Matched'; // Converting the message into JSON format.$SuccessLoginJson = json_encode($SuccessLoginMsg); $first_name = $check[0]; $last_name = $check[1]; $email = $check[2]; $profession = $check[3];// Echo the message. echo $SuccessLoginJson ; } else{ // If the record inserted successfully then show the message.$InvalidMSG = 'Enter valid phone number' ;// Converting the message into JSON format.$InvalidMSGJSon = json_encode($InvalidMSG);// Echo the message. echo $InvalidMSGJSon ; } mysqli_close($con);?>上面的代码是 100% 正确的。[在网页上测试]在我的本机代码中,首先我检查手机号码 => 如果手机号码正确[存在于数据库中],那么该用户可以使用该 JSON 响应转到下一页。
2 回答
LEATH
TA贡献1936条经验 获得超6个赞
您收到的某些数据似乎不是string value。您只能设置string valuefor Textinput。检查接收到的数据的值并确保数据是string.
如果你只是想摆脱错误,
navigation.navigate("Profile",
{EmailId: JSON.stringify($email),
Name: JSON.stringify($firstname+$lastname),
Profe : JSON.stringify($profession),
mobileno : JSON.stringify(UserMNO),
});
- 2 回答
- 0 关注
- 136 浏览
添加回答
举报
0/150
提交
取消