Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Simple personalisation code

Posted on 2004-04-06
11
Medium Priority
?
201 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 120 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
 
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 80 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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)

670 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