Solved

Simple personalisation code

Posted on 2004-04-06
11
192 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
Technology Partners: 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

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 …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

685 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