Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 23rd, 2008, 08:03 AM
Registered User
 
Join Date: May 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to zone8567
Default Question in login script

Hi, I am currently working on a project on asp login. Login.asp seems okie since i am able to login the. After i login, it should link to default.asp, which is supposed to display the profile of the user from a database. However, default.asp did load but nothing appear on the webpage. There is also no error msg at all. I will include the script for login.asp and default.asp below. Please feel free to comment. Thanks a lot!



---------------------------------------------------------------- login.asp --------------------------------------------------------------------------

<HTML>
<style type="text/css">
<!--
.style1 {
 font-size: 36px;
 font-weight: bold;
}
-->
</style>
<BODY>

      <div align="center">
        <p>&nbsp;</p>
        <p>
      <%
  Response.Expires = 0

   If Request.Form("cmdLogin") <> "" Then
    Dim strUsername
  Dim strPassword
  Dim Con
  Dim rsQuery

  strUsername = Replace(Request.Form("txtUsername"),"'","''")
  strPassword = Request.Form("txtPassword")

  Set Con = Server.CreateObject("ADODB.Connection")
  Set rsQuery = Server.CreateObject("ADODB.Recordset")

  dbname="www.mdb"
  cnpath="DBQ=" & server.mappath(dbname)
  Con.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & cnpath


  Set rsQuery = Con.Execute("SELECT Password,Username FROM UserDB WHERE Username='" & strUsername & "'")
  If rsQuery.EOF Then
   Response.Write "Username not found."
   %>
            <br>
            <br>
            <%
   Response.Write("<a href=Login.asp>Login again</a>")
  Else
   If strPassword = rsQuery("Password").Value Then
    'set sessions
    Session("Username") = "[" & rsQuery("Username").Value & "]"


    'Cookie code
    Response.Cookies("NEVERGUESSUsername")=rsQuery("Us ername").Value
    Response.Cookies("NEVERGUESSUsername").Expires=Now () + 10
    Response.Cookies("NEVERGUESSPassword")=rsQuery("Pa ssword").Value
    Response.Cookies("NEVERGUESSPassword").Expires=Now () + 10


    Response.Redirect "Default.asp"
   Else
    Response.Write "Invalid Password."
    %>
             <br>
             <br>
             <%
    Response.Write("<a href=Login.asp>Login again</a>")
   End If
  End If
   Else
%>
      <span class="style1">Welcome to RFIC Profile Database</span></p>
        <p>&nbsp;</p>
      </div>
<form name="form1" method="post" action="Login.asp">
<TABLE BORDER=0 align="center">
       <TR>
            <TD>Username</TD>
          <TD><INPUT TYPE="TEXT" NAME="txtUsername"> </TD>
       </TR>
       <TR>
            <TD bgcolor="#FFFFFF">Password</TD>
         <TD><INPUT TYPE="PASSWORD" NAME="txtPassword" > </TD>
       </TR>
     </TABLE>
     <br>
  <CENTER>
    <input name="cmdlogin" type="submit" id="submit" value="Login" >
    <input type="reset" name="cmdReset" value="Reset" >
  </CENTER>
</form>
<%
   End If
%>

</BODY>
</HTML>



---------------------------------------------------------------- default.asp --------------------------------------------------------------------------



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HEAD>
     <TITLE>login.1.asp</TITLE>
     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</HEAD>
<html>
<body>
<%

Response.Expires=0

Dim Con
Dim rsQuery
Dim strAction
DIm strSubmit
Dim intID
DIm strName
Dim strMessage

 Set Con = Server.CreateObject("ADODB.Connection")
 Set rsQuery = Server.CreateObject("ADODB.Recordset")
 strAction = Request.QueryString("Action")
 strSubmit = Request.Form("Submit")

 dbname="www.mdb"
 cnpath="DBQ=" & server.mappath(dbname)
 Con.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & cnpath

 If Session("Username") = "" Then
  If Request.Cookies("NEVERGUESSUsername") <> "" Then
   Set rsQuery = Con.Execute("SELECT Password,Username FROM UserDB WHERE Username='" & Request.Cookies("NEVERGUESSUsername") & "'")
   If NOT rsQuery.EOF Then
    If Request.Cookies("NEVERGUESSPassword") = rsQuery("Password").Value Then
     Session("Username") = "[" & rsQuery("Username").Value & "]"
     Application("Users" & Session("Start")) = Session("Username")
    End If
   End If
  End If
 end if

 intID = Request.QueryString("ID")
 If intID = "" Then intID = 0
 If strSubmit = "" Then strSubmit = " "
 If strAction = "" Then strAction = " "

Set rsQuery = Con.Execute ("SELECT * FROM UserDB WHERE ID=" & intID)
If not rsQuery.EOF then
%>
<table width="1224" border="1">
  <tr>
    <td width="176">Name</td>
    <td width="966"><%Response.write rsQuery("Name")%></td>
  </tr>
  <tr>
    <td>Job Title</td>
    <td><%Response.write rsQuery("Job")%></td>
  </tr>
  <tr>
    <td>Department</td>
    <td><%Response.write rsQuery("Department")%></td>
  </tr>
  <tr>
    <td>Phone Number</td>
    <td><%Response.write rsQuery("Phone")%></td>
  </tr>
  <tr>
    <td>Fax Number</td>
    <td><%Response.write rsQuery("Fax")%></td>
  </tr>
  <tr>
    <td>Office</td>
    <td><%Response.write rsQuery("Office")%></td>
  </tr>
  <tr>
    <td>Email</td>
    <td><%Response.write rsQuery("Email")%></td>
  </tr>
  <tr>
    <td>Biography</td>
    <td><%Response.write rsQuery("Biography")%></td>
  </tr>
  <tr>
    <td>RF IC Work in NTU</td>
    <td><%Response.write rsQuery("RFIC")%></td>
  </tr>
  <tr>
    <td>Research Interest</td>
    <td><%Response.write rsQuery("Interest")%></td>
  </tr>
  <tr>
    <td>Selected Projects</td>
    <td><%Response.write rsQuery("Project")%></td>
  </tr>
  <tr>
    <td>Major Research Accomplishment</td>
    <td><%Response.write rsQuery("Accomplishment")%></td>
  </tr>
</table>
<%
End if
%>
</body>
</html>


 
Old May 25th, 2008, 06:57 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

TIP - Very broad question. You should be more specific and post only problematcic code for the best results here. People who give thier time here want to see you have done your best to help yourself.

Without going through all your code I assume rsQuery is an empty record set. Have you written your query:

et rsQuery = Con.Execute ("SELECT * FROM UserDB WHERE ID=" & intID)

to the browser and run it directoy to see f your have results?

Wind is your friend
Matt
www.elitemarquees.com.au





Similar Threads
Thread Thread Starter Forum Replies Last Post
login script: user can't hit "return" for login dmerrill Java Basics 13 July 14th, 2006 07:25 PM
login script jstewie Javascript How-To 1 July 13th, 2005 12:52 PM
login script Apocolypse2005 Javascript 3 June 24th, 2005 04:07 PM
login script problem hosefo81 PHP How-To 9 August 20th, 2004 11:28 AM
Login Script natmaster PHP How-To 10 June 19th, 2003 03:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.