|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Creating a login with access
I am trying to create a login based on 2 tables...1. Members 2. Register. My code first checks the Members table to see if the memberno exist. If not it returns an error message. Then it checks to see if the member is already registered from the register table. if the member is registered it gives an error msg. If the member is in the member table and is not registered, it lets the member create an account in the register table... However I am unable to insert a record into the table....below is my code...Any help will be appreciated...
-------------------------------------------- <%if Request.QueryString("return")="yes" then bMemberNo= trim(Request.Form("bMemberNo")) BclubName= trim(Request.Form("BclubName")) bUserName = trim(Request.Form("bUsername")) bpassword=trim(Request.Form("bpassword")) bfirstname=trim(Request.Form("bfirstname")) bLastname=trim(Request.Form("bLastname")) %> <% set MemberSearch=server.CreateObject("ADODB.recordset") set CustomerSearch=server.CreateObject("ADODB.recordset") 'SqlMember="Select memberid,memberno,clubno from members where memberno='"&bMemberNo&"'and clubno='"&BclubName&"'" MemberSearch.Open "Select memberid,memberno,clubno from members where memberno='"&bMemberNo&"'and clubno='"&BclubName&"'",Application("login_ConnectionString") if not MemberSearch.EOF then bchecked=1 bMemberid=MemberSearch.Fields("memberid") MemberNo=MemberSearch.Fields("memberno") clubno=MemberSearch.Fields("clubno") 'SqlSelect="Select * from register where MemberNo='"&MemberNumber&"'and clubno='"&clubno&"'" CustomerSearch.Open "Select * from register where MemberNo='"&MemberNo&"'and clubno='"&clubno&"'",Application("login_ConnectionString") if CustomerSearch.RecordCount>0 then session("MemberRegistered")=1 response.Redirect "ClubMemberSign_copy(2).asp?&bUserName="&bUserName&"&bmemberno="&bMemberno&"&bclubno="&bclubName&"&bFirstName="&bFirstname&"&bLastName="&bLastName&"" end if CustomerSearch.Open "INSERT into register (MemberNo,clubno,firstname,lastname,email,password ,checked) values ('"&MemberNo&"','"&clubno&"','"&bfirstname&"','"&blastname&"','"&bemail&"',"&bchecked&")",Application("login_ConnectionString") 'myconn.execute(SqlInsert) 'CloseConnection myconn Response.Redirect("ClubRegSuccess.asp") else session("MemberCheck")=1 response.Redirect "ClubMemberSign_copy(2).asp?&bUserName="&bUserName&"&bmemberno="&bMemberno&"&bclubno="&bclubName&"&bFirstName="&bFirstname&"&bLastName="&bLastName&"" end if 'CloseConnection myconn end if %> <html> <head> <meta NAME="GENERATOR" Content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> </head> <body bgcolor="white"> <center> <p><br> <strong><font color="#000066">Enter Your Details Here !!</font></strong> <br> </p> <p></p> <table width="1157" border="0" cellspacing="2" cellpadding="0"> <tr align="left" valign="top"> <td width="189" height="438"></td> <td width="529" height="178"> <form name="addressForm" action="ClubMemberSign_copy(2).asp?return=yes" method="post"> <%if session("count")=1 then session("count")=0 Response.Write("<STRONG><font color=#70000>Sorry,Your Email Exists..Try Again !!</font></STRONG><br><br>") end if %> <% if session("memberRegistered")=1 then session("memberRegistered")=0 Response.Write("<STRONG><font color=#70000>Sorry,You are already registered</font></STRONG><br><br>") end if %> <% if session("MemberCheck")=1 then session("MemberCheck")=0 Response.Write("<STRONG><font color=#70000>Sorry,You Are Not A Registered Club Member ...</font></STRONG><br><br>") end if %> <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="529"> <tr> <td width="143"><font color="black" face="timesnewroman">Member Number</font></td> <td width="383"><input name="bMemberno" size="20"> </td> </tr> <tr> <td width="250"><font color="black" face="timesnewroman">ClubName</font></td> <td width="195"> <% set recordClub=server.CreateObject("ADODB.Recordset") recordClub.Open "select * from ClubDetails order by clubname",Application("login_ConnectionString") %> <select id="select1" name="bClubName"> <%while not recordClub.EOF %> <option value="<%=recordClub.Fields("clubno")%>"> <%=recordClub.Fields("clubname")%></option> <% recordClub.MoveNext() wend %></select></td> </tr> <tr> <td width="250"><font color="red" face="timesnewroman">E-MailAddress</font></td> <td width="195"> <input name="bUserName" value="<%=request("bUserName")%>" size="20"> </td> </tr> <tr> <td width="250"><font color="red" face="timesnewroman">Password</font></td> <td width="195"><nobr> <input type="password" name="bpassword" size="20"> <font color="#7f7f7d" size="2">(* atleast 4 characters )</font></nobr> </td> </tr> <tr> <td width="250"><font color="red" face="timesnewroman"><nobr> Re-enterPassword</nobr></font></td> <td width="195"><input type="password" name="bpasswordNew" size="20"> </td> </tr> <tr> <td width="250"><font color="black" face="timesnewroman">First Name</font></td> <td width="195"> <input name="bFirstName" value="<%=request("bFirstname")%>" size="20"> </td> </tr> <tr> <td width="250"><font color="black" face="timesnewroman">Last Name</font></td> <td width="195"> <input name="bLastName" value="<%=request("bLastName")%>" size="20"> </td> </tr> <tr> <td width="143"> </td> </tr> </table> <p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p> </form> <p> </td> <td width="431" height="438"> </td> </tr> </table> </center> </body> </html> |
|
#2
|
|||
|
|||
|
I think the problem is with this set of code? Right now you say if the member is registered then you redirect to a signup form with all the info. Then you have an end if. After which you have the insert statement and then you have your else statement (if they are a member but not registered). So your insert statement is never triggered.
Code:
if CustomerSearch.RecordCount>0 then
session("MemberRegistered")=1
response.Redirect "ClubMemberSign_copy(2).asp
&bUserName="&bUserName&"&bmemberno="&bMemberno
&"&bclubno="&bclubName&"&bFirstName="&bFirstname&"&
bLastName="&bLastName&""
end if
CustomerSearch.Open "INSERT into register
(MemberNo,clubno,firstname,lastname,email,password
,checked) values
'"&MemberNo&"','"&clubno&"','"&bfirstname&"','"&blastname&"','"
&bemail&"',"&bchecked&")",Application("login_ConnectionString")
'myconn.execute(SqlInsert)
'CloseConnection myconn
Response.Redirect("ClubRegSuccess.asp")
else
session("MemberCheck")=1
response.Redirect "ClubMemberSign_copy(2).asp
&bUserName="&bUserName&"&bmemberno="&bMemberno&"&
bclubno="&bclubName&"&bFirstName="&bFirstname&"&
bLastName="&bLastName&""
end if
I'm thinking what you could do is an elseif session("MemberCheck") = 0 then do the insert. That way you can display your error message and have the form repopulated with all the info and then have insert done. You are using a post and request.form, so I'm a little puzzled as to why you are passing the info as well in a querystring. But I haven't tried this myself so maybe you have a reason for it??? If you just submitted the form to itself, then presumably you won't need to use a response.redirect? I try as far as possible to avoid passing info (particular username etc in querystrings because of the potential for SQL injection attacks.) Last edited by aspnewbie : March 22nd, 2003 at 11:37 AM. |
|
#3
|
|||
|
|||
|
thank you for your response...i shall try that and see
|
|
#4
|
||||
|
||||
|
just on the 2 table situation - sounds like there's a lot of redundant data occurring. Why are you using 2 tables? Why not just use a boolean (true/false) field in the members table to represent whether or not someone is registered?
|
|
#5
|
|||
|
|||
|
Yo man help me i am new to VB.NET
Can you send me that example you doing Members and registors table. I need to learn these things
Also if any one have any VB with Access that includes reservation system like a hotel management system or any other reservation system, if they can give to me it would be a graet help. Thank you ALL My E-mail: URL |
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > Creating a login with access |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|