title: How to get the client machine name using php / javascript
body: <p>I need to get the machine name and ip using php/javacript - when I run the webpage on the localhost I am getting the correct computer name and ip address but when I put the page on the webserver and run the same online - the code is returning the ip address of the client machine only NOT the name of machine-name.</p>
  
  <p>I somehow need to get the client machine name and save it in the database for later operation.</p>
  
  <p>So I tried in three ways:</p>
  
  <p>Method 1 (php):</p>
  
  <pre><code>gethostbyaddr($_SERVER['REMOTE_ADDR']); -- return the ip
  
  
  getenv('COMPUTERNAME'); -- return the ip only
  </code></pre>
  
  <p>Method 2(php):</p>
  
  <pre><code>echo shell_exec('echo  %computername%'); -- return none instead of client computer name
  </code></pre>
  
  <p>Method 3 (javascript):</p>
  
  <pre><code>alert(window.location.hostname);
  </code></pre>
  
  <p>None of them are not working.</p>
  
  <p>I'm seeking your assistance.</p>
  
  <p>Thank you.</p>