I'm trying to send data from the client to the server. The client runs a simple python script that uses the 'request' library. The server side consists of another simple php script using the $_POST.
I need the webpage to update depending on the data that is given through the client program.
Here is the python script:
import requests
url = "http://xxxxxxx.com/php_files/text_data.php"
d = {'test': 'It works!'}
r = requests.post(url, data = d)
print r.status_code, r.reason
print r.text
And here is the php code:
<!DOCTYPE = html>
<html>
<head>
<h1>
<?php
$txt = $_POST['test'];
echo $txt;
?>
</h1>
</head>
</html>
I need the php page to display 'It works!' on h1 as this is the value that is being passed. But for some reason, it does not display anything
r.text prints the required format with 'It works!' in the < h1 > tags, but the same does not get displayed in the actual website.
I've also tried var_dump($txt). It gives me a NULL value.
Any help would be gladly appreciated.