title: How to pass a variable from PHP to Android Studio (made with android Volley)
body: <p>I have a working registration/login app. I built it using an Android volley that uses String Request. After logging in, I need to put the user id into an edittext or textview to pass it into another page. </p>
  
  <p>Here's my PHP code:</p>
  
  <pre><code>&lt;?php
  
  if($_SERVER['REQUEST_METHOD']=='POST'){
  
  include 'DatabaseConfigThesis.php';
  
  $con = mysqli_connect($HostName,$HostUser,$HostPass,$DatabaseName);
  
  $Email = mysqli_real_escape_string($con, $_POST["Email"]);
  $Password = mysqli_real_escape_string($con, $_POST["Password"]);
  
  
  $Query = $con-&gt;prepare("SELECT * from UserAccTable where Email= ? AND Password= ? ");
  $Query-&gt;bind_param('ss', $Email, $Password); 
  $Query-&gt;execute();
  
  $records= array();
  $result = $Query-&gt;get_result();
   while ($data = $result-&gt;fetch_assoc())
  {
   $records[] = $data;
  $UserID=$data['UserID'];
  }
  
  if(isset($result)){
  
  echo "Data Matched";
  }
  else{
  echo "Invalid Username or Password Please Try Again !";
  }
  
  }
  else{
  echo "Check Again";  
  mysqli_close($con);
  ?&gt;
  </code></pre>
  
  <p>I stored the user id from the array to $UserID, now all i need is to store it into my android app. I tried searching online for something similar but i didn't use JsonRequest in my android app.</p>
  
  <p>Here is my android app code:</p>
  
  <pre><code>public class AddUser extends AppCompatActivity {
  EditText EtUSerName,EtUserCon,EtUserEmail,EtUserPass;
  Button btUserReg;
  RequestQueue requestQueue;
  ProgressDialog progressDialog;
  String NameHolder, ContactHolder, EmailHolder,PasswordHolder,UserIDThrow;
  int result;
  String HttpUrl = "http://192.168.254.107:81/UserAccDatabaseTable/UserRegistration.php";
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_add_user);
  EtUSerName=findViewById(R.id.UserRegName);
   EtUserCon=findViewById(R.id.UserRegContact);
  EtUserEmail=findViewById(R.id.UserRegEmail);
  EtUserPass=findViewById(R.id.UserRegPass);
  
  btUserReg=findViewById(R.id.btnUserRegister);
  
  requestQueue = Volley.newRequestQueue(AddUser.this);
  progressDialog = new ProgressDialog(AddUser.this);
  
  btUserReg.setOnClickListener(new View.OnClickListener() {
                               @Override
                               public void onClick(View view) {
                                   progressDialog.setMessage("Please Wait, We are Inserting Your Data on Server");
                                   progressDialog.show();
  
                                   // Calling method to get value from EditText.
                                   GetValueFromEditText();
  
                                   StringRequest stringRequest = new StringRequest(Request.Method.POST, HttpUrl,
                                           new Response.Listener&lt;String&gt;() {
                                               @Override
                                               public void onResponse(String ServerResponse) {
  
                                                   // Hiding the progress dialog after all task complete.
                                                   progressDialog.dismiss();
  
                                                   // Showing response message coming from server.
                                                   Toast.makeText(AddUser.this, ServerResponse, Toast.LENGTH_LONG).show();
                                                   result = 0;
  
                                               }
  
                                           },
                                           new Response.ErrorListener() {
                                               @Override
                                               public void onErrorResponse(VolleyError volleyError) {
  
                                                   // Hiding the progress dialog after all task complete.
                                                   progressDialog.dismiss();
  
                                                   // Showing error message if something goes wrong.
                                                   Toast.makeText(AddUser.this, volleyError.toString(), Toast.LENGTH_LONG).show();
                                                   result = 1;
                                               }
                                           }) {
                                       @Override
                                       protected Map&lt;String, String&gt; getParams() {
  
                                           // Creating Map String Params.
                                           Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
  
                                           // Adding All values to Params.
                                           params.put("Name", NameHolder);
                                           params.put("ContactNo", ContactHolder);
                                           params.put("Email", EmailHolder);
                                           params.put("Password", PasswordHolder);
  
  
                                           return params;
                                       }
  
                                   };
  
                                   // Creating RequestQueue.
                                   RequestQueue requestQueue = Volley.newRequestQueue(AddUser.this);
  
                                   // Adding the StringRequest object into requestQueue.
                                   requestQueue.add(stringRequest);
                                   if(result==0 ){
  
                                       new Handler().postDelayed(new Runnable() {
                                           @Override
                                           public void run() {
                                               Intent intent =new Intent(AddUser.this,UserLog.class);
                                      startActivity(intent);
                                           }
                                       }, 5000);
                        }
                       else if(result==1){
                      Toast.makeText(AddUser.this, "Register Failed, Try Again!", Toast.LENGTH_SHORT).show();
  
                                   }
  
                               }
  
                           }
  );
  }
  
  // Creating method to get value from EditText.
  public void GetValueFromEditText(){
  
      NameHolder = EtUSerName.getText().toString().trim();
      ContactHolder = EtUserCon.getText().toString().trim();
      EmailHolder = EtUserEmail.getText().toString().trim();
      PasswordHolder= EtUserPass.getText().toString().trim();
  
  }}
  </code></pre>