I am writing a php code in which i am trying to implement the following
- I have made a exe program in c++ which takes a string input from the user and then displays the output;
- Now in php, i am calling this program using passthru(), system(). like passthru('/var/php/hash')
- my code ask user to input a string & then i am passing this string as an argument with passthru function. echo passthru("/usr/local/bin/php/hashargu $p");
- but i am facing problem here. if i passes single word string, then it works. but when i try to pass a string of more than one word, it does not work. plz help. my code is .............

<?php
/* Get the posted value of the form if there is one */
$p = empty($_POST['p']) ? null : $_POST['p'];
?>
<html>
<head><title>Hash testing</title></head>
<style type="text/css">
    table {border-collapse: collapse;}
    table, td, th {border: solid 1px #ccc;}
    th {background: #e1e1e1;border-color: #999;}
    td, th {padding: 0.25em;}
    td.algo {font-weight: bold;}
    tr.on td {background: #f0f0f0;}
</style>
<body>
    <h1>String hashing</h1>
    <form method="post" action="<?php echo basename(__FILE__) ?>">
        <p><label for="p">Enter a string to hash:</label><br /><input id="p" type="string" name="p" value="<?php echo $p ?>" /></p>
        <p><input type="submit" name="submit" value="Hash It" /></p>
    </form>
    <?php /* If there is a posted value use it */ ?>
    <?php if ($p): ?>
    <hr />
    <h2>Your hash chain for <em><?php echo $p ?></em> is</h2>  
    <?php
    [B]echo passthru("/usr/local/bin/php/hashargu $p");[/B]
    ?>
     <?php endif; ?>
</body>
</html>

Use double quotes around the parameter:

echo passthru("/usr/local/bin/php/hashargu \"$p\"");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.