Ping tool script in PHP

ping tool

Source

PHP ping tool script

The Power of PHP could be integrated with os to perform basic operations, like this.

Here a small piece of code in PHP pings to hosts via o.s . Only trick abot this script is that it calls the system routines for perfom function,nice feature of server side scripting.The script can be run on Linux as well as Windows by detect the server o.s itself.


Enjoy the Ping tool in PHP:


<html>

<h1> Ping tool </h1>

<form action="" method="post">

enter host name or ip address: <input type="text" name="t1" />

<input type="submit" value = "ping it"/>

</form>

<?php

//ping tool in php

$host = "";

if(isset($_POST['t1']) && $_POST['t1']!= "")

{

$host = $_POST['t1'];

}

else

{

die("please select a host to ping");

}

echo "ping results for $host <br><br>";

$p1 = "ping -l 2 $host";

$p2 = "ping -n 2 $host";

if(exec("uname"))

{

echo "<br>";

system($p1);

}

if(exec("ver"))

{

echo "<br>";

system($p2);

}

?>

</html>


source: khalsalabs.com

Comments 2 comments

myra 3 years ago

thanks


Jagadeesh 2 years ago

Hi.

I used this tool but it not showing any result. any error in code or

i did any mistake. pl check my URL.

http://whatis-myip.com/ping.php

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working