使用 HTML 表单获取域(地址)IP
我正在尝试编写一个脚本,用户将地址或域放入区域输入中,脚本返回同一地址/域的 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="✔" />
</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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
那么,您的
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 ofdomain
. Once you correct those two errors your form should work.您的字段名称是
domain
,表单名称是host
,因此您执行以下操作:编辑:
your field name is
domain
, form name ishost
, so you do this:Edit :