Check ip address of host or website with PHP function and HTML form
I have create a HTML file called “checkipform.html” with a HTML form in it:
For the HTML form, it has a text field and a submit button, the text field is for the user to type in the URL of the website for checking the IP address. After the submit button being pressed, it will direct us to a php file named “showip.php”:
<html> <form name ="aform" action="showip.php" method="post"> Enter the website you like to check the IP address: <input name="address" type="text" /> <input name="Submit" type="submit" value="check IP" /> </form> </html>
For “showip.php”:
First we create a PHP variable to store the website address which the user input into the HTML form:
$website = $_POST['address'];
Then we run the PHP function gethostbyname() to get the IP address. We also create another PHP variable to store the result:
$ip = gethostbyname($website);
Now we print out the result to the screen:
echo "The IP of $website is $ip";
All together we have for “showip.php”:
<?php $website = $_POST['address']; $ip = gethostbyname($website); echo "The IP of $website is $ip"; ?>
Similar Posts:
- MD5 – insert an encrypted string or password to the MySQL database with HTML form and PHP
- Delete records from MySQL database with HTML form and PHP
- Display data from MySQL database with HTML form and PHP
- Delete table from MySQL database with HTML form and PHP
- Fetch the data from a HTML form with PHP





