1

HI

Im trying to figure out a way to differenciate between free users and premium users in a mysql database.

Both users need to register with thier username, password and email. When premium users register though, i need a way of distinguising them from feee uers once in the users table.

Is there a way of autamatically populating a field in the table when a user registers, or am I barking up the wrong tree

thanks

Rifki

4 Answers 4

1

When a free user signs up, do

INSERT INTO user
  SET username = "$username",
      password = "$password",
      email = "$email",
      premium = 0

for the premium ones:

INSERT INTO user
  SET username = "$username",
      password = "$password",
      email = "$email",
      premium = 1

(don't forget to use addslashes() with username and email; and md5() with the password)

Sign up to request clarification or add additional context in comments.

Comments

1

Well, create field 'premium' with default value 0. During premium registration, set it to 1.

1 Comment

Sorry, could you give a bit more detail?
0

This should add a column on your users table that will let you query if someone is a premium member or not (assuming you are using MySQL):

ALTER TABLE 'users' ADD COLUMN 'premium' ENUM('0', '1') DEFAULT '0';

2 Comments

IM sorry my sql is not too good, but am learning fast. Could you give an example of how to query a premium member using php?
php.net/manual/en/book.mysql.php you are looking for mysql_query() and mysql_fetch_array() or mysql_fetch_assoc()
0

First, make new column in your users table:

alter table users add isPremium bool;

I would then assume there is some sort of logical operation you can do on the PHP side that would differentiate free and premium users. For example, maybe the credit card information is set or something. Let's just say you have an $isPremium variable that you set to one or zero depending on those conditions. Your php code should look roughly like this:

$query = "insert into users (username, password, isPremium) values('$username', '$password', '$isPremium');";
mysql_query($query);
'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.