php: variable in the href, anomalous value

anerdev

I have this code and I don't understand why there are these problems. Why "192.168.1.200" is replied every time ? Is wrong how I set the variable ?

Thank you

1)

<?php echo "<a href='$ipint'>$ipint</a>"; ?>

The output of this is:

http://192.168.1.200/192.168.1.200

2)

<?php echo "<a href='$ipext'>$ipext</a>"; ?>

The output of this is:

http://192.168.1.200/2.234.169.198

I've used another mode, with same output problem (but with plus :9091):

<a href="<?php echo $ipint ?>:9091/">

The output is:

http://192.168.1.200/192.168.1.200:9091/

-

<?php

$ipint = $_SERVER['SERVER_ADDR'];
$ipext = file_get_contents('http://phihag.de/ip/');

$ipclient = explode(".", $_SERVER['REMOTE_ADDR']);

if ($ipclient[0] == 192) {
    $piip = $ipint;
    }
        else {
            $piip = $ipext;
    };  

?>

<html>

<head>

<title>Pi</title>
<meta charset="UTF-8">

</head>

<body>

<h1 align="center">Pi</h1>
<h5 align="center">

IP interno: <?php echo "<a href='$ipint'>$ipint</a>"; ?>
|
IP esterno: <?php echo "<a href='$ipext'>$ipext</a>"; ?>

</h5>
<hr />

<h4>Service:</h4>

<ul>
    <li><a href="<?php echo $ipint ?>:9091/">Transmission</a></li>
    <li><a href="">Downloads folder</a></li>
    <li><a href="">Dashboard</a></li>
</ul>

</body>

</html>
MegaAppBear

Add "http://" to the beginning of your href. Like this:

<?php

$ipint = $_SERVER['SERVER_ADDR'];
$ipext = file_get_contents('http://phihag.de/ip/');

$ipclient = explode(".", $_SERVER['REMOTE_ADDR']);

if ($ipclient[0] == 192) {
    $piip = $ipint;
    }
        else {
            $piip = $ipext;
    };  

?>

<html>

<head>

<title>Pi</title>
<meta charset="UTF-8">

</head>

<body>

<h1 align="center">Pi</h1>
<h5 align="center">

IP interno: <?php echo "<a href='http://$ipint'>$ipint</a>"; ?>
|
IP esterno: <?php echo "<a href='http://$ipext'>$ipext</a>"; ?>

</h5>
<hr />

<h4>Service:</h4>

<ul>
    <li><a href="http://<?php echo $ipint ?>:9091/">Transmission</a></li>
    <li><a href="">Downloads folder</a></li>
    <li><a href="">Dashboard</a></li>
</ul>

</body>

</html

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related