Friday, February 18, 2022

[FIXED] how to configure config.inc.php to have a loginform in phpmyadmin

Issue

Do I have to download any files in order to have a login form in php. I've asked this a million times but I'm not sure if you guys gets the question or not. All I want is a login form In phpmyadmin. Wherein you will input your username and password. DO I have to create any php login form or is it already included when you install wampserver. I've already configured the config.inc.php in C:\wamp\apps\phpmyadmin3.2.0.1 . Here is what it looks like when I don't include any password. What do I have to edit? I'm beginner and so eager to have that login form already but I don't get any relevant answers.

<?php

    /* Servers configuration */
    $i = 0;

    /* Server: localhost [1] */
    $i++;
    $cfg['Servers'][$i]['verbose'] = 'localhost';
    $cfg['Servers'][$i]['host'] = 'localhost';
    $cfg['Servers'][$i]['port'] = '';
    $cfg['Servers'][$i]['socket'] = '';
    $cfg['Servers'][$i]['connect_type'] = 'tcp';
    $cfg['Servers'][$i]['extension'] = 'mysqli';
    $cfg['Servers'][$i]['auth_type'] = 'config';
    $cfg['Servers'][$i]['user'] = 'root';
    $cfg['Servers'][$i]['password'] = '';
    $cfg['Servers'][$i]['AllowNoPassword'] = true;

    /* End of servers configuration */

    $cfg['DefaultLang'] = 'en-utf-8';
    $cfg['ServerDefault'] = 1;
    $cfg['UploadDir'] = '';
    $cfg['SaveDir'] = '';

    ?>

Solution

First of all, you do not have to develop any form yourself : phpMyAdmin, depending on its configuration (i.e. config.inc.php) will display an identification form, asking for a login and password.

To get that form, you should not use :

$cfg['Servers'][$i]['auth_type'] = 'config';

But you should use :

$cfg['Servers'][$i]['auth_type'] = 'cookie';

(At least, that's what I have on a server which prompts for login/password, using a form)


For more informations, you can take a look at the documentation :

'config' authentication ($auth_type = 'config') is the plain old way: username and password are stored in config.inc.php.

'cookie' authentication mode ($auth_type = 'cookie') as introduced in 2.2.3 allows you to log in as any valid MySQL user with the help of cookies.
Username and password are stored in cookies during the session and password is deleted when it ends.



Answered By - Pascal MARTIN

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.