I have a very simple question ... I have a two input text field and a output text field in php page (index.php) and a multiply function code in Python (add.py). Now I want to take the input from php page and calulate the result within python funtion and print the result on php output text field. I do not have any idea how to do it.
index.php
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
Input 1: <input type="text" name="number" value="<?php echo $input1;?>">
<span class="error">* <?php echo $inputErr;?></span>
<br>
<br>
Input 2: <input type="text" name="number" value="<?php echo $email;?>">
<span class="error">* <?php echo $inputErr;?></span>
<br>
<br>
Output:
<textarea name="output" rows="5" cols="40">
<?php echo $output;?>
</textarea>
<br>
<br>
<input type="submit" name="submit" value="Submit">
</form>
multiply.py
number1 = int(input("Enter first number: "))
number2 = int(input("Enter second number: "))
mul = number1 * number2
print("Multiplication of given two numbers is: ", mul)
addthat multiplies two numbers. Something that PHP is also quite capable of doing by the way, so I'm assuming this is just an example. Secondly, it's a python script designed to handle command line input. Why do you want to build that, and then automate from a PHP script?execcommand. Something likeexec('python ./multiply.py', $result);, but you also need to get that python script to accept values from the command line, like @bruno-desthuilliers described in his answer.