I have an html page and a login.php to set up a simple login page (frontend). In the following login.php page, I need to retrieve the entered useame and password from the html page (I did this in the first 2 lines), then I need to pass both of this information to a backend (my partner). The backend expects a GET useame and password, which apparently is the problem because I can't get it to be authenticated despite entering the correct useame and password. I found that when I did echo $response; and echo $var in the code shown that nothing was retued and this might be the problem. Another potential problem is that the frontend POST data and the backend's expected GET data is incompatible.
<?php
$useame = $_POST["useame"];
$password = $_POST["password"];
$_POST2 = ['useame' => $useame,
'password' => $password];
$ch = curl_init('https://wtfbbq.edu/blahblahblah.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST2);
$response = curl_exec($ch);
echo $response;
curl_close($ch);
$var = json_decode($response, true);
echo $var;
if ($var['authenticated']){ // https://wtfbbq.edu/blahblahblah.php yields the following: {"authenticated":false,"success":false,"error":"Expected POST with useame and password"}
echo 'You have successfully logged in.';
}
else{
echo 'Failed login.';
}
