Here is my Json Code I want make user login using User_Id form Json File
<?php
require '../db_connect.php';
if (isset($_GET['username']) && isset($_GET['password']))
{
$myusername = $_GET['username'];
$mypassword = $_GET['password'];
$sql = "SELECT * FROM user_registration WHERE (username = '$myusername' or email = '$myusername' or phone = '$myusername')";
$result = mysqli_query($con,$sql);
if(mysqli_num_rows($result)>0){
$response["VerifiedMember"] = array();
$row = mysqli_fetch_array($result);
$VerifiedMember = array();
$id=$row['id'];
$phone=$row['phone'];
$reg_type=$row['register_type'];
$stored_salt = $row['salt'];
$stored_hash = $row['hashed_password'];
$check_pass = $stored_salt . $mypassword;
$check_hash = hash('sha512',$check_pass);
if($check_hash == $stored_hash){
$VerifiedMember['user_id'] = $id;
$VerifiedMember['first_name']=$row['first_name'];
$VerifiedMember['phone']=$row['phone'];
array_push($response["VerifiedMember"], $VerifiedMember);
if(!empty($phone)&& $reg_type==1){
$sql="select * from user_otps where user_id='".$id."'";
$result = mysqli_query($con,$sql);
if(mysqli_num_rows($result)>0){
$row = mysqli_fetch_array($result);
if($row['verified']==0)
{
//no product found
$response["success"] = 0;
$response["message"] = "failure";
// echo no users JSON
echo json_encode($response);
}
else
{
//no product found
$response["success"] = 1;
$response["message"] = "success";
// echo no users JSON
echo json_encode($response);
}
}
}
else{
//no product found
$response["success"] = 1;
$response["message"] = "success";
// echo no users JSON
echo json_encode($response);
}
//echo json_encode($response);
}
else{
//no product found
$response["success"] = 0;
$response["message"] = "invalid";
// echo no users JSON
echo json_encode($response);
}
}
else{
//no product found
$response["success"] = 0;
$response["message"] = "invalid";
// echo no users JSON
echo json_encode($response);
}
}
?>
Android Code is here but its showing me correct details of user in lOG file bt i m unable to go next activity using Intent in andoriod and there of log file is pasted below please help me
06-13 13:08:06.503 30430-30570/com.shreejienterprisenic.register D/TESS ::: {"VerifiedMember":[{"user_id":"23","first_name":"karan","phone":""}],"success":1,"message":"success"}
public class NewLogin extends ActionBarActivity {
private EditText editTextUserName;
private EditText editTextPassword;
private ProgressDialog pDialog;
JSONParser jsonParser = new JSONParser();
public static final String USER_NAME = "USERNAME";
String username;
String password;
String result;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_login);
editTextUserName = (EditText) findViewById(R.id.et_email);
editTextPassword = (EditText) findViewById(R.id.et_password);
}
public void invokeLogin(View view) {
new loginAccess().execute();
}
class loginAccess extends AsyncTask<String, String, String> {
String access;
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(NewLogin.this);
pDialog.setMessage("Login...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(false);
pDialog.show();
username = editTextUserName.getText().toString();
password = editTextPassword.getText().toString();
}
@Override
protected String doInBackground(String... arg0) {
List<NameValuePair> params = new ArrayList<NameValuePair>();
String url = "www.sample.com/home_webservice.php";
JSONObject json = null;
try {
params.add(new BasicNameValuePair("username", username));
params.add(new BasicNameValuePair("password", password));
json = jsonParser.makeHttpRequest(url, "GET", params);
Log.d("TESS :: ", json.toString());
String status = json.getString("VerifiedMember");
Log.d("Success Response :: ", status);
if (status.equals("VerifiedMember")) {
Intent i = new Intent(NewLogin.this, MainActivity.class);
startActivity(i);
}
else if
(json.getString("VerifiedMember").trim().equalsIgnoreCase("failed")) {
Toast.makeText(NewLogin.this, "Please enter the correct details!!", Toast.LENGTH_LONG).show();
}
} catch (Exception e1) {
// TODO Auto-generated catch block flag=1;
e1.printStackTrace();
}
return null;
}
protected void onPostExecute(String file_url) {
pDialog.dismiss();
}
}
}
Here's an example of the JSON I'm getting back:
{"VerifiedMember":[{"user_id":"15","first_name":"jaxi","phone":null}],"success":1,"message":"success"}
What is the cause of the exception?