如何在php表单中在IP地址之前添加链接地址
我试图发布用户IP地址与跟踪IP位置的链接,我有下面的php代码。我想在这个如何在php表单中在IP地址之前添加链接地址,php,forms,Php,Forms,我试图发布用户IP地址与跟踪IP位置的链接,我有下面的php代码。我想在这个http://whatismyipaddress.com/ip/108.44.33.225 <?php if(isset($_POST['submit'])){ $to = "email@example.com"; $from = $_POST['email']; $first_name = $_POST['first_name']; $last_name = $_POST['la
http://whatismyipaddress.com/ip/108.44.33.225
<?php
if(isset($_POST['submit'])){
$to = "email@example.com";
$from = $_POST['email'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$ip=$_SERVER['REMOTE_ADDR'];
$subject = "Email IP submission as link";
$message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['message'];
$message .= "IP Address:" <a href="http://whatismyipaddress.com/ip/. $ip .">. $ip</a>";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent. Thank you ";
}
?>
您的代码存在连接问题,请尝试以下操作
$message .= "IP Address: <a href='http://whatismyipaddress.com/ip/".$ip."'>$ip</a>";
$message.=“IP地址:”;
而不是
$message .= "IP Address:" <a href="http://whatismyipaddress.com/ip/. $ip .">. $ip</a>";
$message.=“IP地址:”;
请更正此行:
$message .= "IP Address: <a href='http://whatismyipaddress.com/ip/". $ip ."'>". $ip."</a>";
$message.=“IP地址:”;
或者你可以试试
$message .= "IP Address: <a href='http://whatismyipaddress.com/ip/$ip'>$ip</a>";
$message.=“IP地址:”;
谢谢,但link不附带ip。我只得到“>这样的链接。任何解决方案,谢谢。谢谢你的时间。