Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Login Form

Status
Not open for further replies.

amal1973

Technical User
Jul 31, 2001
131
0
0
US
Lets say that I have friends and family .I would like to create an ASP login Form that will direct the user if he has family to the family page And if he was a friend to the friends page. I would really appreciate any help in developing this form. Also if there is a ready scripts that I could customize to my project

Thanks a million
 
Very simple. Make a table containing the list of all the users. Classify each user whether they be friends or relatives. For example, you have table named USERS in your database with this structure:
Code:
USER_ID    PASSWORD  USER_NAME  USERTYPE
jd         deer      John Doe      R
mm         eminem    Mary Lamb     F

The user types 'R' means relative and 'F' means friend.

Medic
 
Medic ...
Thank you for your fast reply.. I think I have got the DB part, but how can I do that using ASP. And how to redirect the user to the write place..Please advice
 
Have the login page check for the USERTYPE field,

i.e
if usertype = r then
response.redirect "relatives.htm"
else
response.redirect "friends.htm"

[tt]
[sub]
quoteleft.gif
Well, that seems to be the situation. But I don't want that. And you don't want that. And Ringo here *definitely* doesn't want that.
quoteright.gif
- Jules
 
amal1973,

Try a code like this and save it as an ASP file.
Take note of the connection string. Customize it to suit the type of database you use. My sample connection string is applicable to a SQL database.

Code:
<HTML>
<HEAD><TITLE>Login</TITLE></HEAD>
<BODY>
<%
  user_id=request.form(&quot;user_id&quot;)
  if user_id=&quot;&quot; then
%>
<form name=&quot;frmLogin&quot; method=post action=&quot;<%=Request(&quot;SCRIPT_NAME&quot;)%>&quot;>
Enter User ID<br>
<input name=&quot;user_id&quot;>
<br>
Enter Password<br>
<input type=password name=&quot;password&quot;>
<input name=&quot;OK&quot; type=&quot;submit&quot;>
</form>
<%
else
  Set CN = Server.CreateObject(&quot;ADODB.connection&quot;)
  CN.Open &quot;Provider=SQLOLEDB.1;Persist Security Info=True;&quot; & _
            &quot;User ID=sa;Password=;&quot; & _
            &quot;Initial Catalog=MyDatabase;Data Source=MyServer&quot;

  set RS = CN.execute(&quot;select * from USERS where USER_ID='&quot; & _
           request.form(&quot;user_id&quot;) & &quot;'&quot;)

  if RS.EOF then 
%>
Invalid Login ID<br>
<a href=&quot;<%=Request(&quot;SCRIPT_NAME&quot;)%>&quot;>Try again</a>
<%
  else
    password=request.form(&quot;password&quot;)
    if trim(RS.Fields(&quot;password&quot;))=trim(password) then 
      if RS.Fields(&quot;usertype&quot;)=&quot;R&quot; then
        response.redirect(&quot;relatives.asp&quot;)
      else
        response.redirect(&quot;friends.asp&quot;)
      end if
    else
%>
Invalid Password<br>
<a href=&quot;<%=Request(&quot;SCRIPT_NAME&quot;)%>&quot;>Try again</a>
<%
    end if
  end if
end if
%>
</BODY>
</HTML>
 
Here are some other connection string samples you may use in place of the one I coded above. If you are using...

Visual FoxPro, try it like this:
Code:
CN.Open &quot;Driver=Microsoft Visual FoxPro Driver; &quot; & _
         &quot;SourceType=DBF;SourceDB=C:\MyDir;&quot;
This example assumes you have the USERS.DBF free table located in C:\MyDir folder

or

MS Access, try it this way:
Code:
CN.Open &quot;Provider=Microsoft.Jet.OLEDB.4.0;&quot; & _
         &quot;Data Source=C:\MyDir\MyDB.mdb;&quot;
This example assumes you have USERS table defined in MyDB.mbd database located in C:\MyDir folder.

HTH

Medic
 
medic ...
thanks for that nice example, but i am having a problem telling me that Canot find file C:\MyDir\MyDB.mdb although i did change the data base to access and did create the database on the C drive ?? can you tell me what am doing wrong
 
medic,
I managed to make it work , you r example did the trick, thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top