Fri, December 13, 2019, 12:03:39
 
Home · Latest · Trends  /  PHP
4

Validate domain name with PHP

rated 4 times [  4] [ 0]  / comments: 0 / hits: 1488  / 3 years ago, sat, sep 10, 2016, 15:13:33
Validate domain name with PHP gethostbyname
<?php
// index.php
if(isset($_POST['submit'])) {
if(get_magic_quotes_gpc()) {
$domainname = htmlspecialchars(stripslashes($_POST['domainname']));
} else {
$domainname = htmlspecialchars($_POST['domainname']);
}
if(!filter_var(gethostbyname($domainname),FILTER_VALIDATE_IP)) {
echo "false";
} else {
echo "true";
}
} else {
?>
<form method="post" action="index.php">
Domain Name<br />
<input class="input" placeholder="example.com" name="domainname" type="text" /><br />
<br />
<input type="submit" value="Submit" name="submit" />
</form>
<?php } ?>
More From » PHP
 

Comments

There are no comments for this Snippet yet
Username
 
Your Comment
 
Share
Snippets
Smarty sort foreach results in Smarty file
3 years ago, sat, sep 10, 2016
List all files in Zip archive with PHP
3 years ago, sat, sep 10, 2016
How to get the current url in smarty file
3 years ago, sat, sep 10, 2016
Grabbing a Favicon from external website
3 years ago, tue, feb 21, 2017
Posted
Michael

Michael

Member since Sep 10, 2016
Total Code Snippets: 5
Total Comments: 0
Location: n/a
Following
User not following anyone yet.