Create new users with "CREATE USERS" or in a table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thomasjon
Forum Newbie
Posts: 1
Joined: Tue Sep 04, 2007 8:04 pm

Create new users with "CREATE USERS" or in a table

Post by thomasjon »

Hi,

I'm pretty new to PHP, having only written code for one web site. I'm planning my next project and in this project there will be a set of users who will be registered by an "admin" user. The admin may add or delete new users through time. Each user will have account information and, of course, a password and username.
The problem is, I'm not clear on what is the best way to establish users of a website with PHP. Is one of the following approaches cleaner or is there some other suggestion you can offer me?

1) Using PHP to send the SQL statement "CREATE USER <user_name> PASSWORD <password>" to create my users for my MySQL db

. . . or . . .

2) Creating in my MySQL db a table (e.g. Table "Users") for storing new users, their passwords, etc.

I'm not clear yet on how to best work with multiple users.

Thanks in Advance,

J.T.
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

You want to create a table called users so that you can programatically give them access to parts of your application.

When you create a user with CREATE USER in mysql it only controls what access that user has to individual tables and sql statements. Usually you will have one database user for your application that gets used throughout your application to create database connections and nothing else.
Post Reply