User registration with activation code
752596Feb 9 2010 — edited Mar 15 2010Good day folks :)
I've been lurking around these forums for a long time and learning a lot, but it seems I've encountered a problem I can't yet find a suitable solution to.
I'm a student and I'm rather new to apex. There are things I've been able to do (even use some jQuery... The names 'Patrick' 'Dan' and 'Tom' immediately come to mind so thank you!) with the help of this forum but some things are really out of my reach. To get to the point, I have an application where I'd like to register users but first they need to click a link of some sort they'd receive by email that activates their account.
There are three types of user - 'ADM' (an administrator) 'AUT' (as in author) and 'STU' (as in student). Students should be able to register their accounts directly, and that's where the trouble lies.
Before I describe the process, the structure of my 'users' table is like this:
*
CREATE TABLE "USERS"
( "USERID" NUMBER NOT NULL ENABLE,
"USERNAME" VARCHAR2(50) NOT NULL ENABLE,
"PASSWORD" VARCHAR2(100) NOT NULL ENABLE,
"EMAIL" VARCHAR2(200) NOT NULL ENABLE,
"NAME" VARCHAR2(100) NOT NULL ENABLE,
"DOB" DATE NOT NULL ENABLE,
"ADD1" VARCHAR2(300),
"ADD2" VARCHAR2(300),
"ADD3" VARCHAR2(300),
"GENDER" VARCHAR2(1) NOT NULL ENABLE,
"BIO" VARCHAR2(1000),
"PHONE1" VARCHAR2(30),
"PHONE2" VARCHAR2(30),
"SECURITYQUESTION" VARCHAR2(100),
"SECURITYANSWER" VARCHAR2(100),
"USERTYPE" VARCHAR2(3) NOT NULL ENABLE,
"ACTIVE" VARCHAR2(1) NOT NULL ENABLE,
"PHOTO" BLOB,
CONSTRAINT "USERS_PK" PRIMARY KEY ("USERID") ENABLE,
CONSTRAINT "USERS_UK1" UNIQUE ("USERNAME", "EMAIL") ENABLE
)
/
CREATE OR REPLACE TRIGGER "BI_USERS"
before insert on "USERS"
for each row
begin
if :NEW."USERID" is null then
select "USERS_SEQ".nextval into :NEW."USERID" from dual;
end if;
end;
/
ALTER TRIGGER "BI_USERS" ENABLE
/
*
As you can see, there is one column of particular interest here, and that is the ACTIVE column. It simply contains a single character that can be any of the following: 'Y' for active user, 'B' for banned user and 'N' for inactive account. When a student registers, the ACTIVE column defaults to N, and they may not do any user actions until their account is activated. When they click on this link that supposedly activates their account, their status is changed to Y. When an administrator bans them, of course their status changes to B, and they may no longer access the site.
The process should flow like this:
1. User registers an account
2. The application confirms registration and emails them an activation link
3. The user views that email and clicks on the link; their account is activated.
What I'm having trouble with is not particularly emailing someone as I've found a tutorial to do that, but instead I would like to know how to generate a link that changes the value in that column when clicked from an external location (like someone's email inbox). The greatest catch is this: My application is not hosted online, it is on my local machine. So the location of apex is at the localhost:8081/link. I'm not sure how to perform either action.
Any help at all is greatly appreciated - I lost many hours researching on this issue already.
Thanks!
-J