Variable assistance please.

Discussion in 'PHP' started by scottro, Aug 27, 2008.

  1. #1
    Hi all, pretty rusty on my php as I haven't used any in nearly a year. I've tried searching around but have been unable to find any answer. The following is my code:

    <form id="blacklisted" name="blform" method="POST" action="test.php">
    <input type="text" name="ip" size="20" >
    <input type="submit" name="submit" value="Check">
    Checking <?php echo $_POST["ip"]; ?>
    <?php
    echo '<pre>';
    system('./rbl.pl "$ip"');
    echo '</pre>';
    ?>

    My problem is that I am trying to get ip passed into the system command there. My echo command works just fine and brings up what I've entered but the second $ip inside of system() acts as if it is not there and runs the command as if there is no option entered. I've tried at least 10 different methods and had no luck.

    Can anyone assist me? Thanks very much in advance.
     
    scottro, Aug 27, 2008 IP
  2. IGiveMoney

    IGiveMoney Peon

    Messages:
    116
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try

    system('./rbl.pl', $ip);
     
    IGiveMoney, Aug 27, 2008 IP
  3. php-lover

    php-lover Active Member

    Messages:
    261
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    58
    #3
    <form id="blacklisted" name="blform" method="POST" action="test.php">
    <input type="text" name="ip" size="20" >
    <input type="submit" name="submit" value="Check">
    </form>
    <?php
    $ip = $_POST['ip'];
    echo 'Checking '.$ip.'<br>';
    echo '<pre>';
    system('./rbl.pl',$ip);
    echo '</pre>';
    ?>
    
    PHP:
     
    php-lover, Aug 27, 2008 IP
  4. scottro

    scottro Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hey guys,

    Thanks for the assist, however, its still functioning in the same way. This is particularly confounding since the "Checking" echo is now echoing the $ip instead of the original one. It almost acts like its running the rbl.pl and then afterwards seeing the , $ip.

    I tried a few slight alterations to the syntax of the system() line but none of those worked either and either had no effect or gave me a parsing error.

    Any other ideas?

    Thanks again,
    Scott
     
    scottro, Aug 28, 2008 IP
  5. scottro

    scottro Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    For those that come searching for answers after me and find this page...
    I found the answer at the following link and was able to slightly modify it to use my command instead of ping.

    www . chipmunk-scripts . com / tutorials / exec.php

    It was EXACTLY what I was looking for.

    Thanks all,
    Scott
     
    scottro, Aug 29, 2008 IP