Reputation: 49
I have a php script on server side that collects data and inserts into MySQL database ;
$sql = "INSERT INTO tbl_marks (value) VALUES ('".$_GET["value"]."')";
I can add values from browser without issues as such ;
http://localhost/write.php?value=100
But I can't post from Python using requests ;
r = requests.post('https://localhost/write.php?', data = {'value':'100'})
There are no errors or warnings but I see that no entries are written to the table from Python. What am I doing wrong ?
Upvotes: 0
Views: 214
Reputation: 78
The PHP you submitted is looking at GET values (Directly from the user by the way. Look into SQL injection attacks), but your python is making a POST request. Try this instead:
r = requests.get('http://localhost/write.php', params={'value': '100'})
Upvotes: 1