Add IP address in input text field
Discuss coding issues, and scripts related to PHP and MySQL.
-
JanMolendijk
- Posts:282
- Location:Holland Rotterdam
Add IP address in input text field
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 ???
Admin
Posts:805
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; ?>"/>
JanMolendijk
Posts:282
Thank you so mutch stupido me i had to use:
Similar Topics
- Block IP address
PHP - MySQL
First post
Strange activity`s (injection)
Pleasant Coursesweb,
I have whole day this visitor their is might a possibility in the code for something like...
Last post
Hello,
You can block that ip address in php, using this code:
if(strpos($_SERVER , '20.117.73') === 0) exit();
For instance, all of these...
- Speech to text without https
General Forum
First post
Pleasant Coursesweb,
Is their anything posible without https for speech to text fill-in ?
Or must I turn my SSL document on the XAMPP-server ?
Last post
Hello,
I don't know about speech to text fill-in.
Anyway, I want to inform you that this forum will be closed for register or posting.
Any...