0

I have looked at the other similar questions to this here on stack overflow, including the method seen [here][1] trying out various methods but I am still encountering the same issue.

here is my php code.

function LogIn($username, $password){
    $url = 'https://www.example.com';
    $data = array('username' => $username, 'password' => $password);

    $options = array(
        'http' => array(
            'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
            'method'  => 'POST',
            'content' => http_build_query($data)
        )
    );

    $context  = stream_context_create($options);
    $result = file_get_contents($url, false, $context);

    if (strpos($result, "incorrect") !== false){
        return false;
    } else {
        if (strpos($res, "Log In") !== false) {
            echo "captcha solve needed - ";
            return false;
        } else {
            return true;
        }
    }

    var_dump($result);
}

I am receiving the following in my php error logs.

[04-Jun-2017 22:24:13 Europe/London] PHP Warning:  file_get_contents(): SSL: Connection reset by peer in /Users/xx/Desktop/xxx/index.php on line 47
[04-Jun-2017 22:24:13 Europe/London] PHP Warning:  file_get_contents(): Failed to enable crypto in /Users/xxx/Desktop/xxxx/index.php on line 47
[04-Jun-2017 22:24:13 Europe/London] PHP Warning:  file_get_contents(https://www.example.com): failed to open stream: operation failed in /Users/xxx/Desktop/xxxx/index.php on line 47

Could anyone please suggest a method I could fix this.

SOLUTION Fixed this by simply upgrading my mamp.

unorthadox
  • 23
  • 3
  • Please format code so it's readable. It's most likely your server isn't configured for https, or is missing a library, so you should also include your setup info as well. If it works with http only as well, that's worth knowing. – Jared Farrish Jun 04 '17 at 21:38
  • 1
    Plus whatever link was intended to be inserted isn't actually there. In addition, this is using streams, not cURL, so that tag should be removed. – Jared Farrish Jun 04 '17 at 21:40
  • Thank you for your replies, I actually just fixed this by upgrading my Mamp to latest version, comes with OpenSSL installed. – unorthadox Jun 04 '17 at 22:07

0 Answers0