Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在react native的TextInput中获取json数据_Php_Json_React Native - Fatal编程技术网

Php 在react native的TextInput中获取json数据

Php 在react native的TextInput中获取json数据,php,json,react-native,Php,Json,React Native,我只是个初学者,帮帮我吧 我想在react native TextInput中获得JSON响应。 [我在react native应用程序中有2个页面。 在第一个页面==>我想要那个JSON数据,并使用那个JSON响应导航到第二个页面 我使用PHP作为服务器端脚本语言。 我的PHP代码是: <?php // Importing DBConfig.php file. include 'DBConfig.php'; // Creating connection. $con = mysqli

我只是个初学者,帮帮我吧

我想在react native TextInput中获得JSON响应。 [我在react native应用程序中有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);
?>
我在此处输入我的手机号码:

我的第二个屏幕[profile]-我想要JSON响应的地方

第二屏的基本代码[配置文件]

<Block middle style={styles.nameInfo}>
                    <Text bold size={28} color="#32325D">
                        {this.props.navigation.getParam("Name")}
                    </Text>
                    <Block width={width * 0.8} style={{ marginBottom: 15 }}>
                      <Input
                        editable = {false}
                        placeholder="Email id"
                        value={this.props.navigation.getParam("EmailId")}
                        style={{marginTop:20, borderRadius:30, borderWidth:3}}
                        iconContent={
                          <Icon
                            size={16}
                            color={argonTheme.COLORS.ICON}
                            name="nav-right"
                            family="ArgonExtra"
                            style={styles.inputIcons}
                          />
                        }
                      />
                    </Block>
                      <Block width={width * 0.8} style={{ marginBottom: 15 }}>
                      <Input
                        editable = {false}
                        placeholder="Mobile Number"
                        value={this.props.navigation.getParam("mobileno")}
                        style={{borderRadius:30, borderWidth:3}}
                        iconContent={
                          <Icon
                            size={16}
                            color={argonTheme.COLORS.ICON}
                            name="nav-right"
                            family="ArgonExtra"
                            style={styles.inputIcons}
                          />
                        }
                      />
                    </Block>
                    <Block width={width * 0.8} style={{ marginBottom: 15 }}>
                      <Input
                        editable = {false}
                        placeholder="profession"
                        value={this.props.navigation.getParam("Profe")}
                        style={{borderRadius:30, borderWidth:3}}
                        iconContent={
                          <Icon
                            size={16}
                            color={argonTheme.COLORS.ICON}
                            name="nav-right"
                            family="ArgonExtra"
                            style={styles.inputIcons}
                          />
                        }
                      />
                    </Block>

                  </Block>
错误是:


失败的属性类型:为“TextInput”提供的“object”类型的属性“value”无效,应为“string”。

您没有正确存储在此状态下收到的信息

您需要存储信息,然后使用其值​​用这个.state.xxx

使用此.setState存储后:

this.setState({profe: YOUR_VALUE})
您应该修改以下内容:

value={this.state.profe}

您收到的某些数据似乎不是字符串值。 您只能为Textinput设置字符串值。请检查所接收数据的值,并确保数据为字符串

如果你只是想消除错误

navigation.navigateProfile, {EmailId:JSON.stringify$email, 名称:JSON.stringify$firstname+$lastname, 教授:JSON.stringify$profession, mobileno:JSON.stringifyUserMNO, };
value={this.state.profe}