I am writing a web app that will use HTML to display a form. Then the user completes the form, and on submit the form is sent to PHP. In the PHP file I have it set up to call and exec() command to a Python file that will return data. But for some reason I am not getting anything back. When I execute the command in terminal it works great, but no response we ran in the web browser.
HTML:
<form id ="nameForm" action="python.php" method="post" target="_blank">
<label>First Name:</label><input type="text" id="firstName" name="firstName"><br>
<label>Last Name:</label><input type="text" id="lastName" name="lastName"><br>
<input type="submit" id="submitName" value="Submit">
</form>
PHP:
$firstName = $_REQUEST['firstName'];
$lastName = $_REQUEST['lastName'];
exec("/opt/http/PythonWeb/web/python pythonName.py " . $firstName . " " . $lastName, $response);
echo $response;
Python:
import sys
def main():
firstName = sys.argv[1]
lastName = sys.argv[2]
output = ""
output += "<html>
"
output += " <head><title></title></head>
"
output += " <body>
"
output += " <p>Hi " + firstName + " " + lastName + "</p>
"
output += " </body>
"
output += "</html>
"
print output
if __name__ == '__main__': main()
Please give me some suggestions as to what may be wrong. I am new to Python, but it's what the boss man wants... so I am going to make this work. Thanks!