-1

I want to send data to php from android

I can send data with post method but I don't send data to $_SERVER

How Can I send data to php $_SERVER

my php code:

<?php
if (!isset($_SERVER['PHP_AUTH_USER'])) {
    header('WWW-Authenticate: Basic realm="My Realm"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Text to send if user hits Cancel button';
    exit;
} else {
    echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
    echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
}
?>

Thanks.

EagleH
  • 107
  • 2
  • 8

1 Answers1

0

In your request you just have to send a header with the name of PHP_AUTH_USER and PHP_AUTH_PW

alireza
  • 514
  • 3
  • 14
  • How Can I send it? – EagleH Sep 11 '18 at 16:15
  • @EagleH It depends on how you are sending your request if you are using volley: [link](https://stackoverflow.com/questions/17049473/how-to-set-custom-header-in-volley-request) – alireza Sep 11 '18 at 16:17