使用 HTML 表单获取域(地址)IP

发布于 2025-01-06 16:19:00 字数 598 浏览 1 评论 0原文

我正在尝试编写一个脚本,用户将地址或域放入区域输入中,脚本返回同一地址/域的 IP。

但脚本一直很糟糕,我尝试在 contact-form.php 上复制相同的内容,但不起作用;有人可以帮助我吗? post方法效果不好。

谢谢大家

<form id="host" action="<?php echo $_SERVER['REMOTE_ADDR']; ?>" method="post" name="host">
<input type="text" placeholder="Address/host.." name="domain" size="14" maxlength="63" value="<?php echo (isset($_POST['host'])) ? $_POST['host'] : ""; ?>">
<input type="submit" value="&#x2714;" />
</form> 
<?php 

$host = $_POST['host'];

$ip = gethostbyname($host);

echo "Ip is : $ip \n";

?> 

I am trying to do a script thats a user put the address or domain in the area input and the script turns back the ip of the same address/domain.

But the script is crapping all time, I've tried to copy the same is on my contact-form.php but is not working; someone can help me? The post method is not working good.

Thanks all

<form id="host" action="<?php echo $_SERVER['REMOTE_ADDR']; ?>" method="post" name="host">
<input type="text" placeholder="Address/host.." name="domain" size="14" maxlength="63" value="<?php echo (isset($_POST['host'])) ? $_POST['host'] : ""; ?>">
<input type="submit" value="✔" />
</form> 
<?php 

$host = $_POST['host'];

$ip = gethostbyname($host);

echo "Ip is : $ip \n";

?> 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

壹場煙雨 2025-01-13 16:19:00

那么,您的 action 应该只是 """contact-form.php"。您的 $host 必须指向您的 domain 的 POST 值。一旦你纠正了这两个错误,你的表格就应该可以工作了。

Well, your action should just be "" or "contact-form.php". Your $host has to point to your POST value of domain. Once you correct those two errors your form should work.

原来分手还会想你 2025-01-13 16:19:00

您的字段名称是 domain,表单名称是 host,因此您执行以下操作:

$host = $_POST['domain'];

编辑:

<?
if(isset($_POST['domain'])){
  $host = $_POST['domain'];
  $ip = gethostbyname($host);
  echo "Ip is : $ip \n"; 
}
?>

<form id="host" method="post">
<input type="text" placeholder="Address/host.." name="domain" size="14" maxlength="63" ><input type="submit" value="Submit" />
</form> 

your field name is domain, form name is host, so you do this:

$host = $_POST['domain'];

Edit :

<?
if(isset($_POST['domain'])){
  $host = $_POST['domain'];
  $ip = gethostbyname($host);
  echo "Ip is : $ip \n"; 
}
?>

<form id="host" method="post">
<input type="text" placeholder="Address/host.." name="domain" size="14" maxlength="63" ><input type="submit" value="Submit" />
</form> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文