HI
Im tryi开发者_开发问答ng 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
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)
Well, create field 'premium' with default value 0. During premium registration, set it to 1.
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';
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);
'
精彩评论