how can i know if the user is logged in react native and pass data to listview + php
I can't pass the data from the logged-in user to the react native.
return fetch('https://entregas24.000webhostapp.com/viewData.php')
.then((response) => response.json())
.then((responseJson) => {
let ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2})
this.setState({
isLoading: false,
dataSource: ds.cloneWithRows(responseJson),
}, function() {
});
})
.catch((error) => {
console.error(error);
});
}
viewUsers=(email, firstName, lastName)=>{
this.props.navigation.navigate('Third', {
email : email,
firstName : firstName,
lastName : lastName,
});
}
return (
<ListView
dataSource={this.state.dataSource}
renderSeparator= {this.ListViewItemSeparator}
renderRow={ (rowData) => <Text style={styles.rowViewContainer}
onPress={this.viewUsers.bind(
this,
rowData.email,
rowData.firstName,
rowData.lastName,
)} >
{rowData.email}
</Text> }
/>
</View>
);
}
For now I'm even just trying to show the data and than edit them. So if someone can help me i really appreciate.
public function viewUser($email, $firstName, $lastName){
$userData = array();
$result = $this->connect()->prepare( "SELECT email, firstName, lastName FROM `users` ");
$result->execute();
$number_of_rows = $result->fetchColumn();
if($number_of_rows > 0) {
while($row = $result->fetch(PDO::FETCH_OBJ)){
echo $row['email'];
}
}
}