Solved

Simple personalisation code

Posted on 2004-04-06
11
186 Views
Last Modified: 2010-04-06
How can I display the user name of my users from the database, once they have logged into my website?

I used this code:

Dear<%=Name%>

which only displays 'Dear'
0
Comment
Question by:zamorin
  • 5
  • 5
11 Comments
 
LVL 33

Expert Comment

by:sajuks
ID: 10771997
Where are you getting the Name value from ?
Dim Name
Name=Request.Querystring("Name")


// A simple eg:
<html>
<body>

<form action="simple.asp" method="get">
First name: <input type="text" name="fname"><br>
<input type="submit" value="Submit">
</form>
Dear
<%
Response.Write( Request.QueryString("fname"))
%>

</body>
</html>
0
 
LVL 5

Author Comment

by:zamorin
ID: 10772143
The user logs in and his name has to be retrieved from the database.
0
 
LVL 33

Expert Comment

by:sajuks
ID: 10772383
can you post your code, i'll try to modify your code itself.

0
 
LVL 5

Author Comment

by:zamorin
ID: 10772433
The username field name in my MySQL database is 'Name'

<HTML><HEAD>
<META content="text/html; charset=unicode" http-equiv=Content-Type>
<META content="Microsoft FrontPage 5.0" name=GENERATOR>
<!-- #INCLUDE file = "../inc-scripts/adocn.asp"-->
<!-- #include file ="../inc-scripts/verifyAdmin.asp"-->
<script Language="JavaScript" src="../inc-scripts/inc-js/common.js"></script>
<script Language="JavaScript" src="../inc-scripts/inc-js/adminlogin.js"></script>
<title></title>
<link rel="stylesheet" type="text/css" href="../front.css">
<meta name="Microsoft Border" content="none">
</HEAD>
<BODY topmargin="0" leftmargin="0">

<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
  <tr>
    <td width="100%">
</td>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
  <tr>
    <td width="100%" bgcolor="#000080">
    <p align="center"><b><font face="Tahoma" color="#FFFFFF" size="4">MAICSA
          Interactive
      </font><font face="Tahoma" color="#FFFFFF" size="4">- Council members</font></b></td>
  </tr>
  <tr>
    <td width="100%" height="10">
    Dear &lt;Logged in members name&gt;</td>
  </tr>
</table>



<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="10">
  <tr>
    <td width="100%"></td>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="10">
  <tr>
    <td width="100%"></td>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" height="10">
  <tr>
    <td width="100%"></td>
  </tr>
</table>
<div align="center">
  <center>
  <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="85%">
    <tr>
      <td width="100%">
      <p align="left"><b><font face="Verdana" size="2">Council Member Downloads</font></b></td>
    </tr>
  </table>
  </center>
</div>
<div align="center">
  <center>


<table style="BORDER-COLLAPSE: collapse" borderColor="#111111" cellSpacing="1" cellPadding="3" width="85%" border="0">
  <tr>
    <td style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana" vAlign="top" width="54%" bgColor="#000000">
    <p align="left"><b><font face="Verdana" color="#ffffff" size="1">Programme</font></b></td>
    <td style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana" vAlign="top" align="middle" width="23%" bgColor="#000000">
    <p align="left"><b><font face="Verdana" color="#ffffff" size="1">Questions</font></b></td>
    <td style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana" vAlign="top" align="middle" width="23%" bgColor="#000000">
    <p align="left"><b><font face="Verdana" color="#ffffff" size="1">Suggested
    Answers</font></b></td>
  </tr>
  <tr>
    <td style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana" vAlign="top" width="54%" bgColor="#cccccc" height="10">
    <font face="Verdana" color="#000000" size="1">Introduction To Malaysian Law</font></td>
    <td style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana" vAlign="top" width="23%" bgColor="#cccccc" height="10">
    <font face="Verdana" size="1">
    <a href="http://192.9.200.182/maicsa3/download/students_qaq_iml_0312.pdf" target="_blank">
    Dec 2003</a> <font color="#000000">(97 KB)<br>
    </font>
    <a href="http://192.9.200.182/maicsa3/download/students_qaq_iml_0306.pdf" target="_blank">
    Jun 2003</a> <font color="#000000">(72 KB) </font></font></td>
    <td style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana" vAlign="top" width="23%" bgColor="#cccccc" height="10">
    <font face="Verdana" size="1">
    <a href="http://192.9.200.182/maicsa3/download/students_qaa_iml_0312.pdf" target="_blank">
    Dec 2003</a> <font color="#000000">(106 KB)<br>
    </font>
    <a href="http://192.9.200.182/maicsa3/download/students_qaa_iml_0306.pdf" target="_blank">
    Jun 2003</a><font face="Verdana" color="#000000"> (117 KB) </font></font>
    </td>
  </tr>
  </table>
  </center>
</div>
<p>&nbsp;</p>
</BODY>
0
 
LVL 33

Assisted Solution

by:sajuks
sajuks earned 30 total points
ID: 10772524
I hope that you have the basic idea  of asp language, if not just go thru this link
http://www.devx.com/getHelpOn/10MinuteSolution/20493

SET objRS = OpenRecord(myCon, strSQL)

so i will just post the relevant code

Dear  <%=objRS("Name")%>
</td>
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 33

Expert Comment

by:sajuks
ID: 10772530
You are mixing html code with asp code, i hope that  
"Dear &lt;Logged in members name&gt;</td>" was just a copy and paste error from your side
0
 
LVL 5

Author Comment

by:zamorin
ID: 10772614
That was an error.

The elements are as follows:

Database table name = 'counciltable'
Field name (User name) = 'Name'

-----------------------------

The code behind that does the login process is as follows:

<%
Sub validateInfo()
      strSQL = "SELECT * FROM councilTable WHERE userName = '" & strName & "' AND password = '" & strPassword & "'"
      SET rsUser = OpenRecord(myCon, strSQL)
      If Not isObject(rsUser) Then
            Response.Write " Err : " & Err.description & " : " & Err.number & "<br>"
            Response.End
      End If
      If rsUser.recordCount > 0 Then
            Response.Cookies("adminID")                  = rsUser("adminID")
            Response.Cookies("adminName")                        = rsUser("adminName")
            Response.Redirect "../main.asp"
      Else
            Response.Redirect "../loginFailure.asp"
      End If
End Sub

Dim myCon, rsUser, strSQL
SET myCon = OpenConn()

dim strName, strPassword, strType
strName            = request.form("pName")
strPassword = request.form("pPassword")

Call validateInfo()
SET myCon = nothing
%>
0
 
LVL 33

Expert Comment

by:sajuks
ID: 10772862
So your code should look like this::

Dear  <%=rsUser.fields("Name")%>
0
 
LVL 5

Author Comment

by:zamorin
ID: 10772992
I tried using these 2 lines, but the displayed page is blank

<%SET rsUser = OpenRecord(myCon, strSQL)%></td>

Dear  <%=rsUser.fields("Name")%>
0
 
LVL 5

Author Comment

by:zamorin
ID: 10789153
When I just add this line:

Dear  <%=rsUser.fields("Name")%>


I get the following error:

Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: ''
/maicsa3/council/main32.asp, line 56

Any help?
0
 

Accepted Solution

by:
DaMacPhisto earned 20 total points
ID: 10813836
Once you have connected to your db, just add this line to your asp code

Session("Name") = rsUser.strName

And then you will be able to get the information back from any page by

Dear <%=Session("Name")%>
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now