5 Years
Discussion Span
Last Post by tamilabisarva

ok this code work's

$ip = gethostbyname('www.example.com');

echo $ip;

but how can' i make it to write in a box url?

Votes + Comments
This will work

Do you want an ajax solution or a traditional submit form? For Ajax - here's an idea - not meant as a full solution:

    <label for = "url">Enter URL:</label>
    <input id="url" />
    <button id="sendurl">Get IP</button>
<div id="ip">
<!-- or use a form instead of vanilla div -->

You can then use jquery or ordinary javascript to send the form data to a php page to do the gethostbyname() and return the data to the 'ip' div. Here's an example of jQuery.

At bottom of the page - before the </body> tag:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    var urlText = $('#url').val();
    $.post("getIP.php", { url: urlText },
       function(data) {

Your getIP.php file should accept the $_POST['url'] variable and then echo out the response to gethostbyname(). NOT TESTED.

Edited by diafol


woow man your good!
I was make few secoundss ago a page named "name1.php" i put the code inside and not works :(.

and watch out at the last line you forgot to close </script>

Edited by cristian.stilpeanu.3


Like I said NOT TESTED and not meant as a complete solution. It'll give you an idea. That's all. Up to you to implement it and play around with it - if you want to use it that is. Good luck.



I suggest you, one of the simple method to find the ip address of a website. To determine the ip address visit [Ip-details.com](http://www.ip-details.com/). This site contains the html code, which is used to get the ip address,isp,country etc. of a website. You can just embed/copy the code and implement to your website to view all the details of an ip.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.