Environment username to php form
Posted: Wed Dec 29, 2010 8:54 am
Having searched for a couple of days I have yet to find the answer to what should be a simple and common issue.
How do I put the "logged in username" into a php form field?
For testing I tried this from the online manual at: http://www.php.net/manual/en/reserved.v ... onment.php
which displays blank.
However, from a cmd prompt (Windows 7) echo %username% correctly displays the logged in user.
Similarly I would like to capture the IP.
I see these done at many sites, but seem to be unable to find the solution.
Shouldn't I be able to set a PHP variable equal to an Environment variable?
How do I put the "logged in username" into a php form field?
For testing I tried this from the online manual at: http://www.php.net/manual/en/reserved.v ... onment.php
Code: Select all
<?php
echo 'My username is ' .$_ENV["USER"] . '!';
?> However, from a cmd prompt (Windows 7) echo %username% correctly displays the logged in user.
Similarly I would like to capture the IP.
I see these done at many sites, but seem to be unable to find the solution.
Shouldn't I be able to set a PHP variable equal to an Environment variable?