php - Fetch JSON data for authenticated user login -


i trying fetch signup details authenticated user login in react native. not working. new react native can wrong doing.

index.js

onpresslogin() {     this.setstate({         isloading: true,         error: '',     });     dismisskeyboard();     fetch('http://10.0.2.2/movies/signup.php' ,{         method: 'get',         headers: {             'accept' : 'application/json' ,             'content-type': 'application/json'          },         body : json.stringify({             contact : this.state.contact,             password: this.state.password         })     }).then((response) =>      {         return response.json();      }).then((response) => {         if(response.json){          const routestack = this.props.navigator.getcurrentroutes();          this.props.navigator.jumpto(routestack[3]);          asyncstorage.multiset([          [ 'contact' , response.contact],          ]);         } else {             alert("invalid login");         }     }); } 

i using php backend.

signup.php

<?php include 'db.php'; $check_json = file_get_contents('php://input'); echo $obj1=json_decode($check_json); $contact=$obj1 ->{"contact"}; $pass=$obj1 ->{"password"}; $prep = $mysqli->prepare("select contact,password signup  contact=? , password=?"); $prep->bind_param("ss",$contact,$pass); $prep->execute(); echo $result1=$prep->get_result(); $count= $result1->num_rows();     if($count>0){                    echo '1';     }    else{        echo'0';    }  ?> 

there no json data on http://10.0.2.2/movies/signup.php..encode data in json.you can try axios fetching json data.if using local server show json encoded output please.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -