how you can create user authentication in php likewise way whenever we attempt to login to some router.

enter image description here

after i go into the url for instance world wide there must be a prompt such as the above image asking password.

which kind of authentication is. how you can code that in php.

NOTE: i must full charge of the server which i run. same with there any special module that should be installed i'm able to do this.

This really is known as Fundamental Auth. Check this out example in the documentation:

if (!isset($_SERVER['PHP_AUTH_USER'])) {
    header('WWW-Authenticate: Basic realm="My Realm"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Text to send if user hits Cancel button';
} else {
    echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
    echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";


Basically, you signal the best headers using the status code of 401 Unauthorized. the browser sees this together with your WWW-Authenticate header and prompts the consumer for you personally. Once this is accomplished, you'll be able to begin to see the password in $_SERVER['PHP_AUTH_USER'] in addition to $_SERVER['PHP_AUTH_PW'].

You need to know though that if you work with fundamental auth, the username/password are sent plaint-text. You have to use HTTPS if you would like any kind of security. Also, based on the application, you will find that there's not a way to effectively "log out". Most browsers recall the username/password for the whole session, and send it with every subsequent request.

This really is fundamental http authentification. You could discover a tutorial around the php.internet page: http://world wide web.php.internet/manual/en/features.http-auth.php

It's essentially a http header, you need to send towards the browser. The http server (apache/nginx) will forward the userdata later on to php like every other $_SERVER parameter.

Take a look article: It does not genuinely have anything related to PHP.

You'll need two files, .htaccess and .htpasswd, which you might generate here: http://world wide