Forums
This topic is locked
Complex Registration system!!
Posted 11 Apr 2002 04:17:34
1
has voted
11 Apr 2002 04:17:34 LiToZ LiToZ posted:
well, i am facing a problem that IF solved it will add alot to my project!! so here it is and i hope i can have some help!!!well, i need to make a registration system that enables a user for using a service for a certain number of times [ according to his registration rank ] !!! so here it comes:
1- i need the first page after he login to check his usage, if he didnt reach his maximum, he is passed freely and enabled to use the service, if not he get a message telling that he cant continue using that service .
2- if he is still permitted to use the service, he enters the page of the service and do what he want [ for example send a greeting card ] and in the next page , after the greeting card is sent, as soon as the page is loaded, his usage is incremented by ONE in his recordset in the database ..
so could anyone please tell me how to do that ?? by the way, i dont have much ASP programming skills, and i am working with Ultradev 4.. so can anyone help me out with that ? or refer me to an extension that does that OR to a free script that does that ???
An example of the script i need is the site www.sms.ac ! it gives the user 5 free sms/day! if he reached that limit he is prevented from sending! but the ONLY difference is that i want my script not to be PER DAY!! but to be PER NUMBER OF USAGE in an open time interval!!
Thanks 4 your patince running through my problem ! <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Edited by - AkMaLiTo-C on 11 Apr 2002 04:20:57
Replies
Replied 11 Apr 2002 12:31:12
11 Apr 2002 12:31:12 Andrew Watson replied:
This is how I would try and acomplish this....
I presume you have a USERS table that contains the user info and username,password etc. that is used to login the user.
Add a number field to this called (somethinglike) USAGECOUNT. the default value should be 0.
Now say for arguments sake you wanted to restrict them to 5 uses of a service.
Right..
The users logs in using th UD login behaviour and weve got the users Username stored in the Sessionvariable MM_Username. Easy!
Now on the page where the service exists, say its a SMS service, you have a form that allows them to send an SMS.
You should also have on this page a recordset from the users table filtered on the MM_Username variable so it returns only the info for the logged on (current) user.
Place a conditional region around the SMS form which states...
<%
If rsUser.Fields.Item("UsageCount".Value <= 5 Then
{HTML CODE FOR THE SMS FORM}
End If
%>
This will only show the SMS form (or whatever) to users who have a usage count of 5 or less.
Now...
Weve got to increment that count every time the service is used. This can be done a few ways, heres one.
PLace the folowing code where it will be executed directly before or afer the service is completed. so if it was a form that posted to a page which sent the SMS message then redirected back to the first page then add this code on the sending page.
(the recordset needs to be open, so dont close it on the first page or recreate it on the sending page)
<%
myIncrement = rsUser.Fields.Item("UsageCount".Value + 1
rsUser.Update (UsageCount, myIncrement)
%>
This should do the trick and again its only one method, theres a few. Experiment and see what suits you best.
CHeers
Leed
Ill see if i can pop up some code you can copy....<img src=../images/dmxzone/forum/icon_smile_sleepy.gif border=0 align=middle>
Edited by - leed on 11 Apr 2002 12:35:18
I presume you have a USERS table that contains the user info and username,password etc. that is used to login the user.
Add a number field to this called (somethinglike) USAGECOUNT. the default value should be 0.
Now say for arguments sake you wanted to restrict them to 5 uses of a service.
Right..
The users logs in using th UD login behaviour and weve got the users Username stored in the Sessionvariable MM_Username. Easy!
Now on the page where the service exists, say its a SMS service, you have a form that allows them to send an SMS.
You should also have on this page a recordset from the users table filtered on the MM_Username variable so it returns only the info for the logged on (current) user.
Place a conditional region around the SMS form which states...
<%
If rsUser.Fields.Item("UsageCount".Value <= 5 Then
{HTML CODE FOR THE SMS FORM}
End If
%>
This will only show the SMS form (or whatever) to users who have a usage count of 5 or less.
Now...
Weve got to increment that count every time the service is used. This can be done a few ways, heres one.
PLace the folowing code where it will be executed directly before or afer the service is completed. so if it was a form that posted to a page which sent the SMS message then redirected back to the first page then add this code on the sending page.
(the recordset needs to be open, so dont close it on the first page or recreate it on the sending page)
<%
myIncrement = rsUser.Fields.Item("UsageCount".Value + 1
rsUser.Update (UsageCount, myIncrement)
%>
This should do the trick and again its only one method, theres a few. Experiment and see what suits you best.
CHeers
Leed
Ill see if i can pop up some code you can copy....<img src=../images/dmxzone/forum/icon_smile_sleepy.gif border=0 align=middle>
Edited by - leed on 11 Apr 2002 12:35:18
Replied 13 Apr 2002 03:59:34
13 Apr 2002 03:59:34 LiToZ LiToZ replied:
Dear leed,
thanks SO much for your VALUABLE, easy to understand help... i have ran through the SAME procedues u mentioned but i faced a problem.. so i'll tell ya exactly how i did everything so u can recognize where is the error...
Connection String: "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=D:\SMS Project\MySmsUsers.mdb"
Database name : MySmsUsers.mdb
Table name : MyUsers
Username column : Username
Password column : password
Usage column : Usage
Main login page : index.asp
service page : SmsSend.asp
.. so when i login from the index.asp it logins corectly.. and then i get that error message in SendSms.asp -->
============================
Microsoft VBScript runtime error '800a01a8'
Object required: ''
/SendSMS.asp, line 25
============================
and here is the code of the whole sendsms.asp page -->
============================
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/SmsUsers.asp" -->
<%
Dim SendSMS__MMColParam
SendSMS__MMColParam = "1"
if (Session("Username" <> "" then SendSMS__MMColParam = Session("Username"
%>
<%
set SendSMS = Server.CreateObject("ADODB.Recordset"
SendSMS.ActiveConnection = MM_SmsUsers_STRING
SendSMS.Source = "SELECT * FROM MyUsers WHERE Username = '" + Replace(SendSMS__MMColParam, "'", "''" + "'"
SendSMS.CursorType = 0
SendSMS.CursorLocation = 2
SendSMS.LockType = 3
SendSMS.Open()
SendSMS_numRows = 0
%>
<html>
<head>
<title>SendSMS</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<%
If rsUsername.Fields.Item("Usage".Value <= 5 Then
Response.Write " Access Granted "
else
Response.Write " Access Denied "
End If
%>
</body>
</html>
<%
SendSMS.Close()
%>
============================
and i tried to make the rsUsername to be rsMyUsers and rsMySmsUsers but no hope,and i also tried to do the If contitional Exactly as u said without putting an else, but it gave me the SAME error. so i wish u know what is wrong with the script ! <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle> .. thanks <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
P.S: i am runing PWS4 and UD4
Edited by - AkMaLiTo-C on 13 Apr 2002 04:01:33
thanks SO much for your VALUABLE, easy to understand help... i have ran through the SAME procedues u mentioned but i faced a problem.. so i'll tell ya exactly how i did everything so u can recognize where is the error...
Connection String: "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=D:\SMS Project\MySmsUsers.mdb"
Database name : MySmsUsers.mdb
Table name : MyUsers
Username column : Username
Password column : password
Usage column : Usage
Main login page : index.asp
service page : SmsSend.asp
.. so when i login from the index.asp it logins corectly.. and then i get that error message in SendSms.asp -->
============================
Microsoft VBScript runtime error '800a01a8'
Object required: ''
/SendSMS.asp, line 25
============================
and here is the code of the whole sendsms.asp page -->
============================
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/SmsUsers.asp" -->
<%
Dim SendSMS__MMColParam
SendSMS__MMColParam = "1"
if (Session("Username" <> "" then SendSMS__MMColParam = Session("Username"
%>
<%
set SendSMS = Server.CreateObject("ADODB.Recordset"
SendSMS.ActiveConnection = MM_SmsUsers_STRING
SendSMS.Source = "SELECT * FROM MyUsers WHERE Username = '" + Replace(SendSMS__MMColParam, "'", "''" + "'"
SendSMS.CursorType = 0
SendSMS.CursorLocation = 2
SendSMS.LockType = 3
SendSMS.Open()
SendSMS_numRows = 0
%>
<html>
<head>
<title>SendSMS</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<%
If rsUsername.Fields.Item("Usage".Value <= 5 Then
Response.Write " Access Granted "
else
Response.Write " Access Denied "
End If
%>
</body>
</html>
<%
SendSMS.Close()
%>
============================
and i tried to make the rsUsername to be rsMyUsers and rsMySmsUsers but no hope,and i also tried to do the If contitional Exactly as u said without putting an else, but it gave me the SAME error. so i wish u know what is wrong with the script ! <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle> .. thanks <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
P.S: i am runing PWS4 and UD4
Edited by - AkMaLiTo-C on 13 Apr 2002 04:01:33
Replied 13 Apr 2002 07:53:23
13 Apr 2002 07:53:23 Hank Tan-Tenn replied:
Hi,
Just taking a <b>very</b> quick look at it, it looks like "rsUsername" should be the name of the recordset ("the object" created earlier: "SendSMS"
SendSMS.Fields.Item("Usage".Value
That way, and it's the only way I know, if you rename your database, only the connection script needs updating -- the code stays the same!
Edited by - akc on 13 Apr 2002 07:59:18
Just taking a <b>very</b> quick look at it, it looks like "rsUsername" should be the name of the recordset ("the object" created earlier: "SendSMS"
SendSMS.Fields.Item("Usage".Value
That way, and it's the only way I know, if you rename your database, only the connection script needs updating -- the code stays the same!
Edited by - akc on 13 Apr 2002 07:59:18
Replied 13 Apr 2002 18:32:33
13 Apr 2002 18:32:33 LiToZ LiToZ replied:
well, i changed the line and made it as:
If SendSms.Fields.Item("Usage".Value <= 5 Then
and the error vanished ! but i got that error :
ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted; the operation requested by the application requires a current record.
/SendSMS.asp, line 26
Notice that line 26 is the line pasted above!! and the DB is full of info also! so whatz wrong ? am really quizzed ! <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
If SendSms.Fields.Item("Usage".Value <= 5 Then
and the error vanished ! but i got that error :
ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted; the operation requested by the application requires a current record.
/SendSMS.asp, line 26
Notice that line 26 is the line pasted above!! and the DB is full of info also! so whatz wrong ? am really quizzed ! <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
Replied 13 Apr 2002 18:32:40
13 Apr 2002 18:32:40 LiToZ LiToZ replied:
well, i changed the line and made it as:
If SendSms.Fields.Item("Usage".Value <= 5 Then
and the error vanished ! but i got that error :
ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted; the operation requested by the application requires a current record.
/SendSMS.asp, line 26
Notice that line 26 is the line pasted above!! and the DB is full of info also! so whatz wrong ? am really quizzed ! <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
If SendSms.Fields.Item("Usage".Value <= 5 Then
and the error vanished ! but i got that error :
ADODB.Field error '800a0bcd'
Either BOF or EOF is True, or the current record has been deleted; the operation requested by the application requires a current record.
/SendSMS.asp, line 26
Notice that line 26 is the line pasted above!! and the DB is full of info also! so whatz wrong ? am really quizzed ! <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
Replied 13 Apr 2002 19:50:21
13 Apr 2002 19:50:21 Hank Tan-Tenn replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Notice that line 26 is the line pasted above!! and the DB is full of info also! so whatz wrong ? am really quizzed ! <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
The error message is pretty informative: the recordset is empty and therefore you can't get the Usage data to test if it's >= 5! So the code stopped on line 26.
<img src=../images/dmxzone/forum/icon_smile_question.gif border=0 align=middle>Why is the recordset empty? I don't know but make sure you go through the login process (assuming that works as it should) before you reach this SendSMS page so that the session variable Username has something. AND make sure the login page uses "Username" rather than something else like "MM_Username", "XYZ_Login_Name" or whatever. Point is, both pages should have a matching session variable name.
Notice that line 26 is the line pasted above!! and the DB is full of info also! so whatz wrong ? am really quizzed ! <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
The error message is pretty informative: the recordset is empty and therefore you can't get the Usage data to test if it's >= 5! So the code stopped on line 26.
<img src=../images/dmxzone/forum/icon_smile_question.gif border=0 align=middle>Why is the recordset empty? I don't know but make sure you go through the login process (assuming that works as it should) before you reach this SendSMS page so that the session variable Username has something. AND make sure the login page uses "Username" rather than something else like "MM_Username", "XYZ_Login_Name" or whatever. Point is, both pages should have a matching session variable name.
Replied 15 Apr 2002 03:57:30
15 Apr 2002 03:57:30 LiToZ LiToZ replied:
Well, i worked it out and changed the filtering in the SendSMS.asp to filter MM_Username intead of Username and it worked ! <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle> Now, i am doing the incrementing Part!!! and i inserted this code:
<%
myIncrement = SendSMS.Fields.Item("Usage".Value + 1
SendSMS.Update (Usage, myIncrement)
%>
and i had this error:
Microsoft VBScript compilation error '800a0414'
Cannot use parentheses when calling a Sub
/ConfirmSend.asp, line 123
SendSMS.Update (Usage, myIncrement)
-----------------------------------^
so i removed the line <b> SendSMS.Update (Usage, myIncrement) </b> and it worked fine and no errors was showed! but it didnt Increment ANYTHING in the database !!
SO i added the line again but removed the () and it became: <b>SendSMS.Update Usage, myIncrement</b> !! and i got this error <b>ADODB.Recordset error '800a0cc1'
ADO could not find the object in the collection corresponding to the name or ordinal reference requested by the application.
/ConfirmSend.asp, line 123
</b>
!!So any help plz?!
Edited by - AkMaLiTo-C on 15 Apr 2002 09:05:32
<%
myIncrement = SendSMS.Fields.Item("Usage".Value + 1
SendSMS.Update (Usage, myIncrement)
%>
and i had this error:
Microsoft VBScript compilation error '800a0414'
Cannot use parentheses when calling a Sub
/ConfirmSend.asp, line 123
SendSMS.Update (Usage, myIncrement)
-----------------------------------^
so i removed the line <b> SendSMS.Update (Usage, myIncrement) </b> and it worked fine and no errors was showed! but it didnt Increment ANYTHING in the database !!
SO i added the line again but removed the () and it became: <b>SendSMS.Update Usage, myIncrement</b> !! and i got this error <b>ADODB.Recordset error '800a0cc1'
ADO could not find the object in the collection corresponding to the name or ordinal reference requested by the application.
/ConfirmSend.asp, line 123
</b>
!!So any help plz?!
Edited by - AkMaLiTo-C on 15 Apr 2002 09:05:32
Replied 16 Apr 2002 05:11:01
16 Apr 2002 05:11:01 Hank Tan-Tenn replied:
>SendSMS.Update (Usage, myIncrement)
Sorry, I'm not familiar with that syntax -- never used it before -- still learning!
Sorry, I'm not familiar with that syntax -- never used it before -- still learning!
Replied 17 Apr 2002 11:01:55
17 Apr 2002 11:01:55 Andrew Watson replied:
OK, Try this.....
<pre id=code><font face=courier size=2 id=code>
<%
myIncrement = SendSMS.Fields.Item("Usage".Value + 1
SendSMS("Usage" = myIncrement
SendSMS.Update
%>
</font id=code></pre id=code>
You must make sure that the recordset (SendSMS) is still open.
Cheers
Leed<font color=red></font id=red>
Edited by - leed on 17 Apr 2002 11:03:12
<pre id=code><font face=courier size=2 id=code>
<%
myIncrement = SendSMS.Fields.Item("Usage".Value + 1
SendSMS("Usage" = myIncrement
SendSMS.Update
%>
</font id=code></pre id=code>
You must make sure that the recordset (SendSMS) is still open.
Cheers
Leed<font color=red></font id=red>
Edited by - leed on 17 Apr 2002 11:03:12