Sep 18, 2019 01:58 PM
(This post was last modified: Sep 18, 2019 02:11 PM by Avispon99.)
I am trying to connect a python script with a simple website that I made in html and php to test through httplib.
The python script for the connection is as follows:
clarification: I had to put htttp with triple 't' to be able to make the post since hack forums does not let me put anything similar to link I no longer have 50 posts, so ignore that
The php document that receives the connection is as follows:
However, when I try the getresponse() of httplib.client I get the answer the following error:
I know that the error is in the python script and not in the php document because when I connect from an HTML page entering the user and the password I get the Welcome message, but when I do it from the python script I get the error .
Anyone here know what I am doing wrong?
The python script for the connection is as follows:
Code
import http.client as ht
import urllib.parse as ub
openConn=ht.HTTPConnection('127.0.0.1:80')
headers = {'Content-Type':'application/x-www-form-urlencoded','Accept':'text/plain'}
param = ub.urlencode({'usertext':'jhona','passtext':'shaki11'})
openConn.request('GET','htttp://localhost/Test_brut/html_te/php/backdoc.php',param,headers)
resp=openConn.getresponse()
read_resp=resp.read().decode()
print(read_resp)The php document that receives the connection is as follows:
Code
$username = $_GET['usertext'];
$password = $_GET['passtext'];
if(isset($username)&& $username=='jhona'){
if(isset($password) && $password == 'shaki11'){
$open_file = fopen('script_ht.html','r');
$read_f='';
while(!feof($open_file)){
$lin=fgets($open_file);
$read_f=$read_f.$lin;
}
fclose($open_file);
echo 'WELCOME '.$username.'<br>'.$read_f;
}
else{
echo "THE PASS IS INCORRECT";
}
}
else{
echo 'No exist';
}However, when I try the getresponse() of httplib.client I get the answer the following error:
Code
Undefined index: usertext in on line 4
Undefined index: passtext in on line 5
No existI know that the error is in the python script and not in the php document because when I connect from an HTML page entering the user and the password I get the Welcome message, but when I do it from the python script I get the error .
Anyone here know what I am doing wrong?

