Solved

Simple personalisation code

Posted on 2004-04-06
11
194 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
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!

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

734 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