Easy ping script, just what you needed

Discussion in 'PHP' started by BHBodeezy, Mar 2, 2010.

  1. BHBodeezy

    BHBodeezy Make Money Online ADMINISTRATOR

    Joined:
    Aug 5, 2009
    Messages:
    438
    Likes Received:
    13
    Trophy Points:
    18
    Location:
    Christmas Island
    Here is an easy way to create a script that will ping your sites, and x amount of times. If you dont have a way to ping your sites, or looking for a better way.

    Make your own! ;)

    Code you will need to use.

    Code:
    <html>
    <head>
    <title>Ping It!</title>
    </head>
    <body>
    <div align="center">
    <?php
    $server = $_POST['server'];
    $count = $_POST['count'];
    ?>
    <h2>Enter your url and times to ping, click ping to begin.</h2>
    <table style="border-width: 1px; border-style: solid;" cellpadding="5" cellspacing="6">
    <form action="ping.php" method="post">
    <tr>
    <td>URL to ping: </td><td><input type="text" value="<?php echo $server; ?>" name="server" id="server" /></td>
    </tr>
    <tr>
    <td>How many times to ping: </td><td><input type="texT" value="<?php echo $count; ?>" name="count" id="count" /></td>
    </tr>
    <td colspan="2"><input type="hidden" value="1" name="submit" /><input type="button" name="submit1" value="Ping" id="submit1" /></td>
    </tr>
    </form>
    </table>
    
    <?php
    if ($_POST['submit'] == "1"){//submitted the form
    
    echo "<br><h2>Results</h2><table style=\"border-width: 1px; border-style: solid;\" cellpadding=\"5\" cellspacing=\"5\"><tr><td>";
    echo "<pre>";
    system("/bin/ping -c $count $server");//perform ping
    echo "</pre>";
    echo "</td></tr></table>";
    
    system("killall -q ping");//kill the process
    
    }
    
    ?>
    </div>
    </body>
    </html>
    
    
    Copy the code, paste into notepad, save as ping.php. Upload that to your server, navigate to the page and let er rip.

    If you have any problems or questions, please let me know.

    Enjoy!
     
  2. handyman

    handyman New Member

    Joined:
    May 20, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    What about Windows? I used the next PHP Pear Class: Net_Ping
     
  3. Master Mind

    Master Mind New Member

    Joined:
    May 27, 2013
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0


    I want to write a simple windows script that allows one pc to ping a host (10.1.1.1) at particular times during the day. How do I go about it?
     
    Last edited: Aug 5, 2013

Share This Page