$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
if ($username == 'admin' && $password == 'secret') {
echo 'Authentication successful.';
} else {
header('WWW-Authenticate: Basic realm="Restricted Area"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authentication failed.';
exit;
}Basic Authentication
Related Posts
More content you might like
Tutorial
bash
How to Create SSL for a Website on Ubuntu
Alternatively, you can use an SSL checker tool like SSL Labs to verify the validity of your SSL installation.
Let's Encrypt certificates are valid for 90 days. Certbot sets up automatic renewal by default, but it’s good practice to manually test it to ensure it’s working:
Oct 21, 2024
Read More Cheatsheet
VPN Services Cheat Sheet: Top Providers and Apps
- Key Features:
- No-log policy.
- Secure Core servers (extra security).
- P2P support.
- Integrated with ProtonMail.
- Free tier available.
- Works with streaming services.
- Pricing:
- Free plan available.
- $9.99/month (monthly plan).
- $5.99/month (1-year plan).
- $4.99/month (2-year plan).
- Supported Platforms:
- Windows, macOS, iOS, Android, Linux, routers.
- Key Features:
- 3,200+ servers in 80+ countries.
- Patented Catapult Hydra protocol for speed.
- 1Password integration.
- Malware and phishing protection.
- No-log policy.
- Pricing:
- Free plan (limited).
- $12.99/month (monthly plan).
- $7.99/month (1-year plan).
- Supported Platforms:
- Windows, macOS, iOS, Android, Linux, routers, Smart TVs.
Aug 21, 2024
Read More Code
javascript
Validate Password Strength
No preview available for this content.
Jan 26, 2024
Read More Code
javascript
Basic Authentication using 'express-basic-auth' middleware
No preview available for this content.
Jan 26, 2024
Read MoreDiscussion 0
Please sign in to join the discussion.
No comments yet. Be the first to share your thoughts!