Created
June 9, 2013 15:47
-
-
Save marijnvdwerf/5744002 to your computer and use it in GitHub Desktop.
Simple login
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 | |
if($_SERVER['REQUEST_METHOD'] !== 'POST') { | |
http_response_code(405); // Method Not Allowed | |
echo 'Data should be POST\'ed'; | |
die(); | |
} | |
if(!isset($_POST['username'])) { | |
http_response_code(400); // Bad Request | |
echo 'Username not specified'; | |
die(); | |
} | |
if(!isset($_POST['password'])) { | |
http_response_code(400); // Bad Request | |
echo 'Password not specified'; | |
die(); | |
} | |
if($_POST['username'] === 'aap' && $_POST['password'] === 'aap') { | |
http_response_code(200); // OK | |
echo 'Success!'; | |
die(); | |
} | |
http_response_code(401); // Unauthorized | |
echo 'Invalid username or password'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment