The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> prompting for username and password pass to mariadb
Jack42
post May 27 2022, 10:02 AM
Post #1





Group: Members
Posts: 8
Joined: 24-May 22
Member No.: 28,363



I created a webform for users to submit data and store the input in the mariadb database. The data input side is working fine. Now I need to create the page where the data is verified and approved or denied. For the data input I used a hard coded username and password in the php. This is what I did in mariadb:
CREATE USER 'username'@localhost IDENTIFIED BY 'password';
GRANT INSERT ON mytable TO 'username'@localhost;
and used those credentials in the PDO.
For the verification side I would like to prompt for a username and password and pass that information to mariadb for PDO usage. The goal is not to create users in Linux, htaccess, mariadb, etc. I am looking to create just 1 username and password for easy maintenance.

Should I have httpd prompt for the username and password? Should I write php to accept a username and password? I come from a windows background where this is usually handled by IIS windows integrated authentication and Active Directory.

This post has been edited by Jack42: May 27 2022, 10:11 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
 
Reply to this topicStart new topic
Replies
CharlesEF
post Jun 1 2022, 03:36 AM
Post #2


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



Well, in that case. You could create a PHP include file. This file should contain a PHP associative array which contains 2 entries. 1 for each login name, password and DB login information. You then require or include the file in your action script, the script that runs when the form is submitted. What ever you call it.

Once the include file is 'require/include' you then have access to the array information. You check the user name / password and if correct you set a session variable for the DB login information. If user name / password are incorrect you send them back to the login page.

You would then use the session variables in all your DB scripts.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic


Reply to this topicStart new topic
15 User(s) are reading this topic (15 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 27th April 2024 - 03:18 PM