Solved

Simple personalisation code

Posted on 2004-04-06
11
188 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Consuming WCF service from Java with callback contract 5 270
Web Application Architecture 6 78
Web Development Tools for MVC 3 91
File names with & character 6 78
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 …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
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)

778 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