I'm making a button within my website that when clicked calls API from another site using PHP. I have to put my login details as variables in my PHP. I've seen some exploits where hackers are able to get the values on PHP variables by typing something in the address bar? Not sure if that's XSS or SQL injection or what, but I've seen where it will print out the PHP code in XML format.
Here's an example:
if (isset($_POST['submit'])) {
$time = time(true);
$prize = 200;
$ID = "my_secret_API_ID";
$Password = "my_secret_API_Password";
$APIcall = json_decode(file_get_contents("https://apiwebsite/developer/$ID/get_info&pw=$Password"), true);
$display = $APIcall ['some_info'];
echo $display;
}
Are my login details safe? Should I make them global variables outside of the $_POST? Should I define them in a separate PHP file entirely and then use an include? Does it make a difference?