0

Getting these errors.

Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0

Warning: Cannot modify header information - headers already sent in Unknown on line 0

My code:

<!DOCTYPE html>
<html>
<head>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

    <!-- Latest compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

</head>
<body>
<div class="jumbotron text-center">
    <h1>My First Bootstrap Page</h1>
    <p>Resize this responsive page to see the effect!</p>
</div>

<form method="post" class="form-horizontal">
    <div class="form-group">
        <label class="control-label col-sm-2" for="site">Site:</label>
        <div class="col-sm-10">
            <input name="site_input" type="text" class="form-control" id="site" placeholder="Enter site">
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" value="getResponse" name="submitButton" name="submitButton" class="btn btn-default">Submit</button>
        </div>
    </div>

</form>
</body>
</html>

<?php


function checkName($username){

    $curl = curl_init();

    if ($curl == false){
        echo "Failed to initialize";
    }
    $timeout = 5;
    curl_setopt($curl, CURLOPT_URL, 'https://api.mojang.com/users/profiles/minecraft/'.$username);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);

    $output = curl_exec($curl);
    $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    curl_close($curl);

    if ($status == "204"){
        echo "<div align=center>".$username."is available!</div>";

    }else{
        echo "Name unavailable!";

    }


}
if (isset($_POST['submitButton'])){
    checkName($_POST['site_input']);

}


?>

Any help would be greatly appreciated. I tried adjusting the setting to -1 as mentioned.

Mike
  • 23,542
  • 14
  • 76
  • 87
Zach Z
  • 83
  • 1
  • 6
  • Is that the response you get from the API call? It In which case the people that write the API need to fix it. Otherwise, follow the instructions or where this question has been asked several times before - no point rewriting it all here. – Robbie Jan 25 '17 at 01:28
  • The API works for sure. It works if I go into the browser. Was working before as well, Only when I added the post form did this start to happen. – Zach Z Jan 25 '17 at 01:31
  • 1
    Did you restart PHP / apache / NGNIX after changing the setting to -1 ? – Robbie Jan 25 '17 at 01:34
  • I got this fixed now. Localhost server was being annoying :P Thanks. – Zach Z Jan 25 '17 at 02:05

0 Answers0