Created
June 22, 2020 18:36
-
-
Save dascenciohz/545cd45648ef33939600379c20283cc5 to your computer and use it in GitHub Desktop.
Endpoint to test Web Server, PHP Server and MySQL Database Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$database = 'dabase_name'; | |
$username = 'user_name'; | |
$password = 'user_password'; | |
$hostname = 'database_host_name_or_ip'; | |
$link = mysqli_connect("$hostname", "$username", "$password"); | |
if (!$link) { | |
header ("Content-Type text/plain"); | |
echo "Status: ERROR \n"; | |
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500); | |
echo mysql_error(); | |
} else { | |
$database_query="YOUR MYSQL QUERY, FOR EXAMPLE... select username from databae.user where user='you_username'"; | |
$result = mysqli_query($link, $database_query); | |
$user = ""; | |
while($result_user = mysqli_fetch_array($result)) { | |
$user = $result_user[0]; | |
} | |
if ($user == 'your_username') { | |
header ("Content-Type text/plain"); | |
header("HTTP/1.1 200 OK"); | |
echo "Status: OK"; | |
} else { | |
echo "Status: ERROR \n"; | |
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment