HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
login page
Post new topic   Reply to topic    HTML Help Forum Index -> ASP
View previous topic :: View next topic  
Author Message
taz2005



Joined: 20 Jun 2006
Posts: 14
Location: BC, Canada

PostPosted: Wed Jul 12, 2006 11:27 am     login page Reply with quote

I need to create a login page where when the user logs in they are sent to another page. I have all of the user pages created and I have a database. All I need is help getting for my login page to the users pages.

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><!-- InstanceBegin template="/Templates/all.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Simply Health Systems - Software Solutions for the Health Care Industry</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../styles.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="../script/swapimage.js"></script>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>

<body topmargin="0" marginwidth=0 marginheight=0 style="margin-top:0px" onLoad="MM_preloadImages('../images/menu1B.gif','../images/menu5B.gif','../images/menu7B.gif','../images/menu9B.gif','../images/menu11B.gif')">
<table align="center" width="720" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="90" align="left" valign="top"><a href="http://www.simplyhealthsystems.com"><img src="../images/bartopL.gif" width="90" height="80" border="0"></a></td>
    <td width="630" align="left" valign="top"><img src="../images/bartopR.gif" width="630" height="80" border="0" usemap="#Map2"></td>
  </tr>
  <tr>
    <td height="22" colspan="2" align="left" valign="top"><table width="720" border="0" cellspacing="0" cellpadding="0">
        <tr align="left" valign="top">
          <td width="64"><img src="../images/menu0.gif" width="20" height="22"></td>
          <td width="88"><a href="../mission/index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','../images/menu1B.gif',1)"><img src="../images/menu1A.gif" name="Image2" width="88" height="22" border="0"></a></td>
          <td width="35"><img src="../images/menu2.gif" width="35" height="22"></td>
          <td width="50"><a href="../team/index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image6','','../images/menu5B.gif',1)"><img src="../images/menu5A.gif" name="Image6" width="50" height="22" border="0"></a></td>
          <td width="35"><img src="../images/menu6.gif" width="10" height="22"></td>
          <td width="134"><a href="../shsrep/index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image8','','../images/menu7B.gif',1)"><img src="../images/menu7A.gif" name="Image8" width="134" height="22" border="0"></a></td>
          <td width="35"><img src="../images/menu6.gif" width="10" height="22"></td>
          <td width="134"><a href="../login/index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image9','','../images/menu14B.gif',1)"><img src="../images/menu14A.gif" name="Image9" width="95" height="22" border="0"></a></td>
          <td width="36"><img src="../images/menu8.gif" width="36" height="22"></td>
          <td width="88"><a href="../whatsnew/index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image10','','../images/menu9B.gif',1)"><img src="../images/menu9A.gif" name="Image10" width="88" height="22" border="0"></a></td>
          <td width="39"><img src="../images/menu10.gif" width="39" height="22"></td>
          <td width="47"><a href="../contact/index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image12','','../images/menu11B.gif',1)"><img src="../images/menu11A.gif" name="Image12" width="85" height="22" border="0"></a></td>
          <td width="64"><img src="../images/menu13.gif" width="30" height="22"></td>
        </tr>
      </table></td>
  </tr>
    <tr> <!-- InstanceBeginEditable name="Body" -->
    <td background="../images/back.gif" colspan="2" align="left" valign="top">
    <table width="100%" border="0" cellspacing="0" cellpadding="5">

        <tr>
          <td height="250" align="left" valign="top">
            <p><a class=breadcrumblink href="http://www.simplyhealthsystems.com">Home</a><a class=breadcrumb>&gt; Login</a><br>
              <br>
              <a class=title>The SHS Team</a></p>
        <table align="center">
          <tr align="left" valign="middle">
            <td width="151" height="45">
              <table width="143" height="50" border="0" cellpadding="0" cellspacing="10">
                <tr><td>User Name</td><td width="200" height="22" valign="middle" align="left"><INPUT TYPE="text" NAME="UserName" class="whbdr" value="<%=request.querystring("UserName")%>"></td></tr>
                <tr><td>Password&nbsp;&nbsp;&nbsp;&nbsp;</td><td valign="middle" align="left"> <INPUT TYPE="password" NAME="Password" class="whbdr"></td></tr>
                <tr><td></td><td valign="middle" align="left"><input type="image" src="../images/go2.gif" width="67" height="29"></td></tr>
              </table>
            </td>
         </tr>
        </table>

        </tr>
      </table>
    </td>
    <!-- InstanceEndEditable --></tr>
  <tr align="left" valign="top">
    <td colspan="2"><img src="../images/barbottom.gif" width="720" height="79" border="0" usemap="#Map"></td>
  </tr>
</table>
</body>
</html>
<%
if Request.QueryString("Status") = "Failed" then
response.write("<script language='Javascript'>alert('Your Login has Failed');</script>")
end if
%>

taz2005



Joined: 20 Jun 2006
Posts: 14
Location: BC, Canada

PostPosted: Wed Jul 12, 2006 11:52 am     Reply with quote

the database is in Access
taz2005



Joined: 20 Jun 2006
Posts: 14
Location: BC, Canada

PostPosted: Wed Jul 12, 2006 12:05 pm     Reply with quote

taz2005 wrote:
the database is in Access

I am really dumb today the database in a .mdb file
degsy



Joined: 23 Feb 2005
Posts: 2440
Location: North East, UK

PostPosted: Fri Jul 14, 2006 11:36 am     Reply with quote

Here is an example using ASP


http://computer-helpforum.com/asp/aspfree/basics/login/login.asp

login.asp
Code:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1

msg = "Please login"

If Request.QueryString("action") = "logout" Then
   Session("user_id") = ""
   msg = "You have been logged out"
End If

If Request.Form("Submit") = "Login" Then
   
   Function validateStr(str)
      temp = str
      temp = Trim(temp)
      temp = Replace(temp,"'","''")
      
      validateStr = temp
   End Function
   
   user_name = validateStr(Request.Form("user_name"))
   user_pass = validateStr(Request.Form("user_pass"))
   
   Set conn=Server.CreateObject("ADODB.Connection")
   conn.Provider="Microsoft.Jet.OLEDB.4.0"
   conn.Open Server.MapPath("login.mdb")
   Set rsLogin = Server.CreateObject("ADODB.recordset")
   rsLogin.Open "SELECT user_id, user_name, user_pass FROM users WHERE user_name = '" & user_name & "' AND user_pass = '" & user_pass & "'", conn
      If NOT rsLogin.EOF Then
         Session("user_id") = rsLogin("user_id")
         Response.Redirect("profile.asp?user_id=" & rsLogin("user_id"))
      Else
         Response.Redirect("login.asp?errmsg=Login failed")
      End If
   rsLogin.Close
   conn.Close
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Login</title>
<style type="text/css">
<!--
.errmsg {
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-size: 12px;
   font-weight: bold;
   color: #FF0000;
   background-color: #FFFF99;
}
body,td,th {
   font-family: Arial, Helvetica, sans-serif;
   font-size: 12px;
   color: #0099FF;
   font-weight: bold;
}
body {
   background-color: #F9F9F9;
}
-->
</style>
</head>

<body>
<%If Len(Request.QueryString("errmsg")) > 0 Then %>
<span class="errmsg">Error: <%=Request.QueryString("errmsg")%></span>
<%ElseIf Len(msg) > 0 Then %>
<span class="errmsg">Message: <%=msg%></span>
<%End If%>
<form name="form1" id="form1" method="post" action="">
  <table width="300" border="0" cellspacing="0" cellpadding="2">
    <tr>
      <td>Username</td>
      <td><input name="user_name" type="text" id="user_name" /></td>
    </tr>
    <tr>
      <td>Password</td>
      <td><input name="user_pass" type="password" id="user_pass" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="Submit" value="Login" /></td>
    </tr>
  </table>
</form>

<%
Set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open Server.MapPath("login.mdb")
Set rsCurrentMembers = Server.CreateObject("ADODB.recordset")
rsCurrentMembers.Open "SELECT user_name, user_pass FROM users", conn

   If Not rsCurrentMembers.EOF Then
%>
<p>Current Members<br />
</p>
<table width="200" border="1" cellspacing="0" cellpadding="2">
  <tr>
    <th scope="col"><div align="left">user_name</div></th>
    <th scope="col"><div align="left">user_pass</div></th>
  </tr>
<%
      While NOT rsCurrentMembers.EOF
%>
  <tr>
    <td scope="col"><%=rsCurrentMembers("user_name")%></td>
    <td scope="col"><%=rsCurrentMembers("user_pass")%></td>
  </tr>
<%
      rsCurrentMembers.MoveNext
      Wend
%>
</table>
<%
   End If
rsCurrentMembers.Close
conn.Close
%>
</body>
</html>




profile.asp
Code:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1

If Session("user_id") = "" Then
   Response.Redirect("login.asp?errmsg=Please login")
End If

Set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open Server.MapPath("login.mdb")
Set rsUser = Server.CreateObject("ADODB.recordset")
rsUser.Open "SELECT * FROM users WHERE user_id =" & Session("user_id"), conn
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Profile</title>
<style type="text/css">
<!--
.error {
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-size: 12px;
   font-weight: bold;
   color: #FF0000;
   background-color: #FFFF99;
}
body,td,th {
   font-family: Arial, Helvetica, sans-serif;
   font-size: 12px;
   color: #0099FF;
   font-weight: bold;
}
body {
   background-color: #F9F9F9;
}
-->
</style>
</head>

<body>
<p>Welcome <%=rsUser("user_name")%>, Your email address is <%=rsUser("user_email")%>
</p>
<p><a href="login.asp?action=logout">Logout</a></p>
</body>
</html>
<%
rsUser.close
conn.close
%>


Database
http://computer-helpforum.com/asp/aspfree/basics/login/login.mdb
taz2005



Joined: 20 Jun 2006
Posts: 14
Location: BC, Canada

PostPosted: Fri Jul 14, 2006 12:32 pm     Reply with quote

Thanks.
That is really helpful
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> ASP All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Webmaster Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial