Search
 
SCRIPT & CODE EXAMPLE
 

PHP

HTTP Authentication example forcing a new name/password

<?php
function authenticate() {
    header('WWW-Authenticate: Basic realm="Test Authentication System"');
    header('HTTP/1.0 401 Unauthorized');
    echo "You must enter a valid login ID and password to access this resource
";
    exit;
}
 
if (!isset($_SERVER['PHP_AUTH_USER']) ||
    ($_POST['SeenBefore'] == 1 && $_POST['OldAuth'] == $_SERVER['PHP_AUTH_USER'])) {
    authenticate();
} else {
    echo "<p>Welcome: " . htmlspecialchars($_SERVER['PHP_AUTH_USER']) . "<br />";
    echo "Old: " . htmlspecialchars($_REQUEST['OldAuth']);
    echo "<form action='' method='post'>
";
    echo "<input type='hidden' name='SeenBefore' value='1' />
";
    echo "<input type='hidden' name='OldAuth' value="" . htmlspecialchars($_SERVER['PHP_AUTH_USER']) . "" />
";
    echo "<input type='submit' value='Re Authenticate' />
";
    echo "</form></p>
";
}
?>
Comment

PREVIOUS NEXT
Code Example
Php :: laravel notion add enviroment 
Php :: How to download file with laravel 
Php :: change php variable value in javascript 
Php :: PHP sha1_file — Calculate the sha1 hash of a file 
Php :: cakephp Not Found error handle in pagination 
Php :: remove a specific element from array inside a loop php 
Php :: how to delete single row from grid in magento 
Php :: php Get location date format 
Php :: Read the index and hashid of the last block in the blockchain 
Php :: create request php-salesforce-rest-api 
Php :: How to list notification from database 
Php :: search a file name and open that file phpstrom 
Php :: change varchar limit in migration file. 
Php :: php $_POST contains 
Php :: php find longest string in array 
Php :: df/mpdf/src/Cache.php on line 21 
Php :: Store Notice 
Php :: Drupal 9 select node data with query conditions using entity type manager 
Php :: Add a watermark to an existing PDF document 
Php :: php date letters 
Php :: WordPress oEmbed Funktion abschalten 
Php :: Add Spatie provider to providers 
Php :: atom emmet php 
Php :: how to check request method in php 
Php :: get user id trougt user code 
Php :: comment_info 
Php :: CURLAUTH_BEARER cannot find 
Php :: Yii2 Dynamic Relational, Eager loading 
Php :: #@923uf8023hFO@I#H# 
Php :: Laravel 8 Factory - One To Many (Polymorphic) Relationship 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =