I need to pass data from a PHP page to a Python script and back. I do it with a form that reminds to a page with this PHP code:
<html>
<body>
<h1>Project</h1>
<h2>Results</h2>
</body>
</html>
<?php
$myHotel->name = $_POST["NAME"];
$hotel_data = json_encode($myHotel); ;
$command = escapeshellcmd("/var/www/html/test.py $hotel_data");
$resultAsString = exec($command);
?>
The JSON is sent back from the Python script:
#!/usr/bin/env python
import sys
import json
print(sys.argv[1]);
The problem, is that i send a JSON string like this:
{"name":"Hotel Roma Sud"}
And I receive something like this:
{name:Hotel Roma Sud}
How can I receive a JSON string or manage to have one? I tried with exec(), json_encode, json_decode... Thanks