John Davidson

Problem with sending data from Python to PHP using POST

0 comments
Message:


I am trying to send data from python to my localhost on rasberry pi but localhost doesn't want to display it. The server responds in python shell but it seems that php doesn't see the data.


python:


import requests
import time

while True:

test = {"1": "4444", "1": "3333"}
responde = requests.post('http://localhost/index.php', headers={'Content-Type': 'application/x-www-forum-urlencoded'}, params = test)
print(responde.url)
print(responde.text)
time.sleep(10)

php(localhost):


While (True){       
if (isset($_POST['1'])){
$data = $_POST['1'];
echo $data;
}
else{
echo "no_data";
exit;
}
}


My Answer:
"key": "value"} _ response = requests.post('http://localhost/test.php', data=test) _ print(response.text) _ time.sleep(5)_php:_

Rate this post

3 of 5 based on 9631 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us