0

I have a php script like this. This doesn't run my script nor print anything on the click of the button. How to do that Also if you have a pointer to php 101 online please let me know

<?php
if ($_GET['run']) {
  # This code will run if ?run=true is set.
ob_start();

passthru("./check_ddts.sh ".escapeshellarg($_POST["CSCui21515"]));
$data = ob_get_clean();
}
?>


<!-- This link will add ?run=true to your URL, myfilename.php?run=true -->
<button type="button" onclick="?run=true">Click Me!</button>
3
  • where do you define your functions passthru() and escapeshellarg()? Commented Jul 22, 2013 at 13:14
  • 2
    @Dave passthru() and escapeshellarg() are native php functions. Commented Jul 22, 2013 at 13:17
  • Really? Learn something new every day. Commented Jul 22, 2013 at 13:55

1 Answer 1

1

Your button is not actually doing anything. The problem is that your onclick attribute should contain javascript which will run when the button is clicked, not a redirect location. Use a form with a submit button instead like this.

<form action="" method="get">
    <input type="submit" name="run" value="Click Me!" />
</form>

I notice in your question that you are also using post data in handling the form, in which case the above will not work. You need to submit the POST data at the same time as you run the script.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.