Page 1 of 1

Add IP address in input text field

Posted: 29 Jan 2017, 15:36
by JanMolendijk
Dear admin i `m thankfully for your support `just great`.
With both examples for <input type="text"> it shows only string(13) but not the whole ip-adress.

Code: Select all

<input type="text" name="from" class="form-control"  value="<?php var_dump($_SERVER['REMOTE_ADDR']); ?>"/></div>

Code: Select all

<input type="text" name="from" class="form-control"  value="<?php function getIP(){
  return getenv('HTTP_CLIENT_IP')?: getenv('HTTP_X_FORWARDED_FOR')?:
 getenv('HTTP_X_FORWARDED')?: getenv('HTTP_FORWARDED_FOR')?:
 getenv('HTTP_FORWARDED')?: getenv('REMOTE_ADDR')?:'UNKNOWN IP';
}
$ip = getIP();

var_dump($ip); 
 ?>"/>
if i place the code without the <input type="text" then it is working normal.
What could i do more to show into the <input type="text" the whole ip-adress ???

Add IP address in input text field

Posted: 29 Jan 2017, 17:02
by Admin
I tested this code; it is working.

Code: Select all

<?php
//returns client ip address
function getIP(){
  return getenv('HTTP_CLIENT_IP')?: getenv('HTTP_X_FORWARDED_FOR')?:
 getenv('HTTP_X_FORWARDED')?: getenv('HTTP_FORWARDED_FOR')?:
 getenv('HTTP_FORWARDED')?: getenv('REMOTE_ADDR')?:'UNKNOWN IP';
}
$ip = getIP();
?>
Your html content..
<input type="text" name="from" class="form-control"  value="<?php echo $ip; ?>"/>

Add IP address in input text field

Posted: 29 Jan 2017, 17:17
by JanMolendijk
Thank you so mutch stupido me i had to use:

Code: Select all

<?php echo $ip; ?>